Java Reference
In-Depth Information
Logger logger
= LoggerFactory.getLogger("recipeLogger");
logger.info("Logging for the first Time!");
logger.warn("A warning to be had");
logger.error("This is an error!");
Logger rollingLogger
= LoggerFactory.getLogger("rollingLogger");
for (int i =0;i < 5000;i++) {
rollingLogger.info("Logging for an event with
:"+i);
}
logging.properties file
handlers = java.util.logging.FileHandler
recipeLogger.level=INFO
.level=ALL
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.pattern=importantLog%g.log
java.util.logging.FileHandler.limit=50000
java.util.logging.FileHandler.count=4
How It Works
To control the size of log files, configure the java.util.logging framework and
specify rolling log files. Choosing the rolling log files option causes the latest informa-
tion to be kept in ImportantApplication0.log . Progressively older informa-
tion will be in ImportantApplication1.log, ImportantApplica-
tion2.log, and so forth. When ImportantApplication0.log fills to the
limit you specify (50,000 bytes in this example), its name will be rotated to Import-
antApplicationLog1.log , and the other files will have their names similarly ro-
tated downward. The number of log files to maintain is determined by the
Search WWH ::




Custom Search