How to set logger level

Hi, where and how do I set the logging level. I've tried

Logger.getLogger(FPB.class.getName()).setLevel(Level.OFF);

in the main method but i still get all INFO: messages.

Try:


Logger.getLogger("").setLevel(Level.OFF);

Thanks, now I get it. ("") is for the root.



It works perfectly.

it also works package wise.


Logger.getLogger("com.jme").setLevel(Level.OFF);
// here, you would still get Log messages from com.jmex packages
Logger.getLogger("com.jmex").setLevel(Level.OFF);
// now all logging is off

You can also set the level using a configuration file, which is handy if you want to change it without recompiling the code.



http://java.sun.com/j2se/1.4.2/docs/guide/util/logging/overview.html#1.8

Making levels below INFO to work can be tricky. The root logger is initialized with default level INFO and default console output handler that has level INFO. So if you want to see messages generated by the logger in your class with levels FINE, FINER and FINEST, you have to make sure they output into the handler that can consume messages with that level. If your logger doesn't have it's own handler, then all the messages will go to the parent's handler.



With the default configuration there is only one console handler attached to the root logger, so you have to call:

Logger.getLogger("").getHandlers()[0].setLevel(Level.FINE); // to enabled Level.FINE



However if you have added extra output handlers, things can quickly get very complicated.