This is the example for log4J v1.2x (The v1.3 development is stopped by the way.) series , "log4j.xml" file.
By using DailyRollingFileAppender, you can log rotate as the date base.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!--Definition of the File Appender -->
<appender name="file" class="org.apache.log4j.DailyRollingFileAppender">
<!-- Date pattern policy -->
<param name="DatePattern" value=".yyyy-ww" />
<param name="File" value="logs/hibernate.log"/>
<!-- Log append -->
<param name="Append" value="true" />
<!-- Log layout -->
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %5p %c{1} - %m%n" />
</layout>
<!-- Default log level -->
<param name="threshold" value="info"/>
</appender>
<!--Console log appender -->
<appender name="stdout" class="org.apache.log4j.ConsoleAppender">
<!-- Default log level -->
<param name="threshold" value="info"/>
<!-- log layout -->
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %5p %c{1} - %m%n"/>
</layout>
</appender>
<root>
<appender-ref ref="stdout"/>
<appender-ref ref="file"/>
</root>
</log4j:configuration>
No comments:
Post a Comment