一旦它们不再是活动日志,我将使用包中的压缩org.apache.log4j.rolling.RollingFileAppender
日志。apache-log4j-extras
这是一个示例附加程序:
<appender name="TRACELOG" class="org.apache.log4j.rolling.RollingFileAppender">
<param name="file" value="logFileName.log" />
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
<param name="FileNamePattern" value="logFileName.%d.log.gz" />
</rollingPolicy>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%t] %C{2} (%F:%L) - %m%n" />
</layout>
<filter class="org.apache.log4j.varia.LevelMatchFilter">
<param name="LevelToMatch" value="trace" />
<param name="AcceptOnMatch" value="true" />
</filter>
<filter class="org.apache.log4j.varia.DenyAllFilter" />
</appender>
我想做的是添加类似这样的东西,<param name="MaxBackupIndex" value="14" />
这样它基本上只能保留 14 天的压缩日志,但是当我尝试使用它时,我收到以下警告:
log4j:WARN No such property [maxBackupIndex] in org.apache.log4j.rolling.RollingFileAppender.