How to set the logging level when using System.Logger

Viewed 250

I'm trying to use System.getLogger, but I can't figure out how to set the log level so that debug messages come out. Here is my simple problem repro:

class LogTest {
        static {
                System.setProperty("java.util.logging.SimpleFormatter.format", "%1$tF: %5$s%n");
                System.setProperty("java.util.logging.ConsoleHandler.level", "FINEST");
        }
        public static void main(String[] args) {
                System.getLogger(LogTest.class.getName())
                        .log(System.Logger.Level.INFO, "info");
                System.getLogger(LogTest.class.getName())
                        .log(System.Logger.Level.DEBUG, "debug");
        }
}

The formatting change works, so it appears that the System.Logger is using the java.util.logging, but the logging level change doesn't seem to be working.

1 Answers
Related