Setting the Log Level of a Logger

The log level of a logger controls the severity of messages that it will log. In particular, a log record whose severity is greater than or equal to the logger's log level is logged.

A log level can be null, in which case the level is inherited from the logger's parent.

Note: Logger handlers also have a log level. A log record must first pass the logger's log level before it is compared to the handler's log level.

// Get a logger Logger logger = Logger.getLogger("com.mycompany"); // Set the level to a particular level logger.setLevel(Level.INFO); // Set the level to that of its parent logger.setLevel(null); // Turn off all logging logger.setLevel(Level.OFF); // Turn on all logging logger.setLevel(Level.ALL);

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.