Monday, March 21, 2011

DailyRollingFileAppender

With the following Log4j configuration


log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.File=sample.log
log4j.appender.R.DatePattern='.'yyyy-MM-dd


The sample.log will be copied to sample.log.2006-06-06, example,

sample.log
sample.log.2006-06-06
sample.log.2006-06-05

---------------------------------------------------------------------------------
  1. name="Rolling" class="org.apache.log4j.RollingFileAppender">
  2. name="file" value="${catalina.home}/logs/test.log" />
  3. name="maxFileSize" value="10000KB" />
  4. name="maxBackupIndex" value="25" />
  5. class="org.apache.log4j.PatternLayout">
  6. name="ConversionPattern" value="[%t] %d{HH:mm:ss,SSS} %-5p %l - %m%n" />
------------------------------------------------------------------------------------
  1. name="Daily" class="org.apache.log4j.DailyRollingFileAppender">
  2. name="file" value="${catalina.home}/logs/test.log" />
  3. name="DatePattern" value="'.'yyyy-MM-dd" />
  4. name="MaxBackupIndex" value="10" />
  5. class="org.apache.log4j.PatternLayout">
  6. name="ConversionPattern" value="[%t] %d{HH:mm:ss,SSS} %-5p %l - %m%n" />



No comments:

Post a Comment

Followers