Reputation: 918
I need to enable Jersey tracing/logging dynamically from my Java EE 7 application. I don't have access to Jersey libraries, my only dependency is javaee-api 7.0.
I tried with logging.properties (JUL), but no success:
handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=ALL
java.util.logging.SimpleFormatter.format=%4$-7s [%3$s] %5$s%6$s%n
#All log level details
.level=ALL
org.glassfish.jersey.level=ALL
org.glassfish.jersey.tracing.level=ALL
client.Client.level=ALL
If I manage to configure it to log everything in console with java.util.logging properties, then I plan to reload logging properties with LogManager dynamically, but I'm stuck at that first step described above.
If it makes difference, application server is Payara 4 and implementation is Jersey 2.
Here's one use case that made me implement something like this:
If one vendor (3rd party system connected using REST) wants me to provide request/response with headers and payload from production system, I could raise the logging level on demand, log that required request and details and then lower the logging level back to normal. Otherwise I would need to use some monitoring app, or proxy in the middle which is not an option.
Upvotes: 2
Views: 453
Reputation: 918
Found the mistake, I was missing the Jersey log handler in my logging properties file: com.sun.jersey.handlers=java.util.logging.FileHandler
If I use this logging.properties file I get the wanted result:
handlers=java.util.logging.FileHandler
java.util.logging.FileHandler.level=ALL
java.util.logging.SimpleFormatter.format=%4$-7s [%3$s] %5$s%6$s%n
#All log level details
.level=ALL
com.sun.jersey.level=ALL
com.sun.jersey.handlers=java.util.logging.FileHandler
java.util.logging.FileHandler.pattern=debugging.log
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
Upvotes: 1