Separately, at my workplace, the following was found:
public class Foo { private final static Logger logger = Logger.getLogger(Foo.class.getName()); public static final void main(String[] args) { ConsoleHandler ch = new ConsoleHandler(); ch.setLevel(Level.FINEST); Foo.logger.addHandler(ch); Foo.logger.setLevel(Level.FINEST); Foo.logger.finest("test"); } }
If you just set the best (exclusively) for the root or handler, then this did not work. When I set both to FINEST , then it works. His explanation was:
Both loggers and its handlers have log levels ... The filtering order is Logger then Handlers. This means that it checks whether it sends the log message first, and then sends the message to individual handlers for filtering.
He further explained this using the following examples:
Logger myLogger has a FINEST level and one ConsoleHandler myHandler which has an INFO level
myLogger.fine("foo") The error message goes beyond the registrar filter, but receives the filter through the handler filter ... nothing is output.
myLogger.info("foo") à skips both filters and displays foo .
Now...
Logger myLogger has INFO level and one ConsoleHandler myHandler which has FINEST level
myLogger.fine("foo") Message about the filter stopping the logs and never gets into the handler ... Displays nothing.
myLogger.info("foo") à skips both filters and displays foo .
Now...
Logger myLogger has a FINEST level and one ConsoleHandler myHandler which has a FINEST level
myLogger.fine("foo") à skips both filters and displays " foo ".
myLogger.info("foo") à skips both filters and displays foo .
jwmajors81 Oct 22 '09 at 18:52 2009-10-22 18:52
source share