Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Debug-level logging

logging has a long and torrid history...but in a nutshell the jetty
approach is to provide a simple mechanism that doesn't force users to
use any one implementation, but allow them to use slf4j, log4j or
logback in any reasonable combination they like :)

cheers,
jesse

--
jesse mcconnell
jesse.mcconnell@xxxxxxxxx



On Thu, Apr 28, 2011 at 12:17, Mark Payne <mark.payne@xxxxxxxxxxx> wrote:
> 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
> _______________________________________________
> jetty-users mailing list
> jetty-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/jetty-users
>


Back to the top