Tuesday, November 1, 2016

Log4J - log file name with date (each day have one log file)

This is the log4j.properties file I used.

 log4j.rootCategory=INFO, console, file  
 log4j.appender.console=org.apache.log4j.ConsoleAppender  
 log4j.appender.console.layout=org.apache.log4j.PatternLayout  
 log4j.appender.console.layout.ConversionPattern=%d{dd MMM yy HH:mm:ss} %c{1} %-5p %x - %m%n  
 
 log4j.appender.file=org.apache.log4j.DailyRollingFileAppender  
 log4j.appender.file.File=/msgs/logs/project.log  
 log4j.appender.file.File.DatePattern='.'yyyy-MM-dd  
 log4j.appender.file.layout=org.apache.log4j.PatternLayout  
 log4j.appender.file.layout.ConversionPattern=%d{dd-MM-yyyy HH:mm:ss} %-5p %c{1}:%L - %m%n  

No comments:

Post a Comment