How to set logger level

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


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



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

It works perfectly.

it also works package wise.

// here, you would still get Log messages from com.jmex packages
// 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.

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.