Logger.setLevel() doesn't enable logging correctly

Posted by ripper234 on Stack Overflow See other posts from Stack Overflow or by ripper234
Published on 2011-01-04T13:58:53Z Indexed on 2011/01/04 14:53 UTC
Read the original article Hit count: 149

Filed under:
|

Situation: I have this log4j logger:

private static final Logger logger = Logger.getLogger(ThisClassName.class);

And am trying to set it programatically through:

Logger.getLogger(ThisClassName.class).setLevel(Level.DEBUG);

Still, DEBUG level prints are swalloed (while INFO prints are printed successfully).

Even this bit has no effect: Logger.getRootLogger().setLevel(Level.DEBUG);

Calling logger.debug("foo") reaches Category.forcedLog() and ConsoleAppender.doAppend(), and then fails (quits) at:

if(!isAsSevereAsThreshold(event.getLevel()))

Any idea why this is happening?

© Stack Overflow or respective owner

Related posts about java

Related posts about log4j