01.
log4j.appender.daily=org.apache.log4j.DailyRollingFileAppender02.
log4j.appender.daily.File=C:/daily.log03.
log4j.appender.daily.DatePattern='.'yyyy-MM-dd-a04.
log4j.appender.rolling.MaxFileSize=5KB05.
log4j.appender.rolling.MaxBackupIndex=106.
log4j.appender.daily.layout=org.apache.log4j.PatternLayout07.
log4j.appender.daily.layout.ConversionPattern=%d [%t] %-2p %c -%m%n
Daily Rolling File Appender in log4j.xml
01.
<?xml version="1.0" encoding="UTF-8" ?>02.
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">03.
04.
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">05.
<!-- File Appender -->06.
<appender name="daily"07.
class="org.apache.log4j.DailyRollingFileAppender">08.
<param name="File" value="log/daily.log"/>09.
<param name="DatePattern" value="'.'yyyy-MM-dd"/>10.
<param name="Append" value="true"/>11.
<layout class="org.apache.log4j.PatternLayout">12.
<param name="ConversionPattern" value="%-5p%c{1}-%m%n"/>13.
</layout>14.
</appender>15.
16.
<root>17.
<priority value ="debug" />18.
<appender-ref ref="daily" />19.
</root>20.
21.
</log4j:configuration>