[logback-user] TRACE messages get through even at DEBUG Level
Andy Ruch
adruch2002 at yahoo.com
Mon Feb 23 22:48:45 CET 2009
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.
Am I configuring something incorrectly?
Thanks,
Andy
More information about the Logback-user
mailing list