Java Reference
In-Depth Information
Table 9-1 . Logging Levels
Logging
Level
Recommendation
Least important of the logging events
Trace
Debug
Use for extra information that helps with debugging
Use for everyday logging messages
Info
Use for recoverable issues, or where the suspicions of a wrong setting/nonstand-
ard behavior happens
Warn
Use for exceptions, actual errors, and things that you really need to know
Error
Fatal
Most important
Note When setting the log level, loggers will log at that level and below. Therefore,
if a logging configuration sets the log level to info , messages at the Info , Warn , Er-
ror , and Fatal levels will be logged.
9-10. Rotating and Purging Logs
Problem
You have started to log information, but the information logged continues growing out
of control. You would like to keep only the last 250KB worth of log entries within your
log files.
Solution
Use SLF4J with java.util.logging to configure rolling logs. In this example, a
logger named recipeLogger is used to log many messages. The output will pro-
duce rolled log files with the most recent logged information in the important Lo-
g0.log file.
loadLoggingConfiguration();
 
Search WWH ::




Custom Search