|Re: [jetty-users] Debug-level logging|
On 28/04/11 15:40, Guy Hillyer wrote:
On 04/28/2011 10:12 AM, Mark Payne wrote:Can anyone tell me what I need to do?For embedded Jetty, I use org.eclipse.jetty.util.log.Log.setLog() to explicitly set the logger, before creating the jetty Server instance. There are several logger classes available in that package that you can pass to Log.setLog, one is for java.util.logging, another for slf4j, and another that just prints to stderr (respectively: JavaUtilLog, Slf4jLog, and StdErrLog). The javadoc for these classes is not very helpful, better to read the source. They are very simple classes. I ended up making my own logger facade class that plays nice with the established use of java.util.logging in the rest of my application.
OK, got it. After some experimenting with a simple test program:If I remove slf4j and log4j from the classpath then it falls back to using default StdErr logging, and setting org.eclipse.jetty.util.log.DEBUG=true produces lots of debug output.
If I put them back then it reverts to using log4j via slf4j and org.eclipse.jetty.util.log.DEBUG has no effect. But I can add
log4j.rootLogger=DEBUG, stdout to log4j.properties and I get the debugging output again. If I want to override the automatic selection of slf4j I add Logger stdErrLogger = new StdErrLog(); Log.setLog(stdErrLogger);before I create my server and I get StdErr logging whatever is on the classpath.
Very flexible, but confusing initially. Thanks for your help folks. Mark
Back to the top