我想在每200 MB之后滚动日志文件并进行gzip或者在一天之后滚动并且gzip以先到者为准
对于它我已完成以下配置(sizebasedtriggeringpolicy with timebasedrollingpolicy),但它仅在文件大小达到200 MB时才有效。
每天滚动日志不起作用
<appender name="MYAPPENDER" class="org.apache.log4j.rolling.RollingFileAppender">
<param name="File" value="${catalina.home}/logs/MY-APP.log"/>
<param name="Threshold" value="DEBUG"/>
<param name="Append" value="true"/>
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
<param name="ActiveFileName" value="${catalina.home}/logs/MY-APP.log"/>
<param name="FileNamePattern" value="${catalina.home}/logs/MY-APP_%d{yyyy-MM-dd}.%i.log.gz" />
</rollingPolicy>
<triggeringPolicy class="org.apache.log4j.rolling.SizeBasedTriggeringPolicy">
<param name="maxFileSize" value="209715200" />
</triggeringPolicy>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{dd/MM/yyyy HH\:mm\:ss}] %-5p [%c.%M(),%4L] - %m%n" />
</layout>
</appender>
我们可以同时使用sizebasedtriggeringpolicy和timebasedrollingpolicy吗?
请在此建议。