An indivual at my workplace found the following to work:
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 root or the handler to finest (exclusively) then it didn't work. When I set both to FINEST then it works. His explanation was:
Both the logger and its handlers have Log Levels… The order of filtering is Logger then Handlers. That means it checks to see if the log message passes the loggers filter first, then sends the message on to the individual handlers for filtering.
He further explained it using the following examples
Logger myLogger has a level of FINEST and a single ConsoleHandler myHandler which has a level of INFO
myLogger.fine(“foo”) à message makes it past the logger’s filter, but gets stopper by the handler’s filter… Nothing output.
myLogger.info(“foo”) à passes both filters and “foo” is output.
Now…
Logger myLogger has a level of INFO and a single ConsoleHandler myHandler which has a level of FINEST
myLogger.fine(“foo”) à message gets stopped by the logger’s filter and never makes it to the handler… Nothing output.
myLogger.info(“foo”) à passes both filters and “foo” is output.
Now…
Logger myLogger has a level of FINEST and a single ConsoleHandler myHandler which has a level of FINEST
myLogger.fine(“foo”) à passes both filters and “foo” is output.
myLogger.info(“foo”) à passes both filters and “foo” is output.