How do I set the Logger log level?
Category: java.util.logging, viewed: 3499 time(s).
In this example you see how we can change or set the Logger log
level. The log level will tell the Logger which particular log message
will be logged.
Logger will only record the log message if the level is equal or
higher than the Logger level. For instance when the level set to
Level.SEVERE, no message other than message logged with Logger.severe(String message)
of Logger.log(Level level, String message) will be logged.
If we run the program above will see the following result displayed:
29 Apr 09 10:06:50 org.kodejava.example.util.logging.LogLevelSetting main SEVERE: This message will be logged. 29 Apr 09 10:06:50 org.kodejava.example.util.logging.LogLevelSetting main INFO: Information message. 29 Apr 09 10:06:50 org.kodejava.example.util.logging.LogLevelSetting main WARNING: Warning message. 29 Apr 09 10:06:50 org.kodejava.example.util.logging.LogLevelSetting main SEVERE: Severe message.
In the result above we see that the "This message won't be logged."
is not displayed.
Download Hundreds of Complimentary Industry Resources
Get hundreds of popular Industry magazines, white papers, webinars, podcasts, and more;
all available at no cost to you. With more than 600 complimentary offers, you'll find
plenty of titles to suit your professional interests and needs.
Click Here and Sign up today!


