[logback-user] TRACE messages get through even at DEBUG Level
Andy Ruch
adruch2002 at yahoo.com
Tue Feb 24 16:05:17 CET 2009
I created JIRA issue LBCLASSIC-109.
Thanks,
Andy
----- Original Message ----
From: Ceki Gulcu <ceki at qos.ch>
To: logback users list <logback-user at qos.ch>
Sent: Tuesday, February 24, 2009 2:37:36 AM
Subject: Re: [logback-user] TRACE messages get through even at DEBUG Level
The problem is caused by the fact that the localLevelReset method in the Logger class inadvertently uses the DEBUG_INT value in the org.slf4j.spi.LocationAwareLogger interface instead of the DEBUG_INT value in ch.qos.logback.classic.Level class.
I will commit a fix in a few minutes.
Ceki Gulcu wrote:
>
>
> Andy,
>
> Thank you for your message. I think the following test reproduces the bug you have encountered.
>
> @Test
> public void levelResetTest() {
> LoggerContext loggerContext = new LoggerContext();
>
> Logger root = loggerContext.getLogger(LoggerContext.ROOT_NAME);
> root.setLevel(Level.TRACE);
> assertTrue(root.isTraceEnabled());
> loggerContext.reset();
> assertFalse(root.isTraceEnabled()); <-- assertion fails
> assertTrue(root.isDebugEnabled());
> }
>
> If so, could you please enter a jira issue at http://jira.qos.ch ? Many thanks in advance,
>
> Andy Ruch wrote:
>> Hello,
>>
>> I'm using SLF4J 1.5.6 and Logback 0.9.15.
>>
>> I'm wanting to reconfigure Logback in my code, but I think I've found a bug. I've copied the following code from the documentation for how to reconfigure Logback.
>>
>> // assume SLF4J is bound to logback in the current environment
>> LoggerContext lc = ( LoggerContext ) LoggerFactory.getILoggerFactory();
>>
>> try {
>> JoranConfigurator configurator = new JoranConfigurator();
>> configurator.setContext( lc );
>> // the context was probably already configured by default configuration
>> // rules
>> lc.reset();
>> configurator.doConfigure( url );
>> }
>> catch ( JoranException je ) {
>> je.printStackTrace();
>> }
>> StatusPrinter.printInCaseOfErrorsOrWarnings( lc );
>>
>>
>> This works fine, except for when my new root logger level is DEBUG. If that is the case,
> > I receive trace messages also. I have tracked the issue down to
> > ch.qos.logback.classic.Logger. When localLevelReset() is called, the
> > effectiveLevelInt is set to DEBUG_INT = 10. If it is the root logger,
> > the level is also set to DEBUG. When the logger is being reconfigured,
>> setLevel() is called with newLevel = DEBUG. Because level == newLevel,
> > nothing happens and the method returns. However, effectiveLevelInt is never
> > being set to ch.qos.logback.classic.Level.DEBUG_INT = 10000. When a TRACE log
> > message is then evaluated, it is sent through because the effectiveLevelInt is still 10,
> > even though Level should be DEBUG.
>
-- Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch
_______________________________________________
Logback-user mailing list
Logback-user at qos.ch
http://qos.ch/mailman/listinfo/logback-user
More information about the Logback-user
mailing list