我的应用程序有log4j.xml。配置是:
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="false" xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %p [%c] - <%m>%n"/>
</layout>
</appender>
<appender name="app" class="org.apache.log4j.rolling.RollingFileAppender">
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
<param name="FileNamePattern" value="/var/log/folder/myApp_new.log.%d{yyyy-MM}.gz"/>
</rollingPolicy>
<param name="File" value="/var/log/folder/myApp_new.log" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<param name="MaxFileSize" value="100kB" />
<param name="MaxBackupIndex" value="10" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %p [%c] - %m%n"/>
</layout>
</appender>
当我添加org.apache.log4j.rolling.RollingFileAppender时,应用程序停止了日志记录。问题在于滚动。我需要使用org.apache.log4j.rolling.RollingFileAppender,因为我希望每天都有新的日志,每个日志都要10MB。 谢谢。