我正在使用log4j1.2.16和log4j附件来根据大小滚动日志文件。我面临的问题是,无论服务器启动和运行时的大小限制,日志都不会被翻转。虽然在根据日志文件大小重新启动服务器时会滚动日志。请参阅下面的log4j配置xml的代码片段:
<appender name="FileAppender" class="org.apache.log4j.rolling.RollingFileAppender">
<param name="Threshold" value="TRACE" />
<param name="Append" value="true"/>
<rollingPolicy class="org.apache.log4j.rolling.FixedWindowRollingPolicy" >
<param name="ActiveFileName" value="C:/File.log" />
<param name="FileNamePattern" value="C:/%i.File_%d{dd-MMM-yyyy}.log.zip"/>
</rollingPolicy>
<triggeringPolicy class="org.apache.log4j.rolling.SizeBasedTriggeringPolicy">
<param name="maxFileSize" value="5000000" />
</triggeringPolicy>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%-12d{dd MMM yyyy HH:mm:ss,SSS}] [%t] [%-5p] %C %M [Line number:%L] %x - %m%n" />
</layout>
</appender>