我在log4j.xml下面使用
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<appender name="file_1" class="org.apache.log4j.RollingFileAppender">
<param name="MaxFileSize" value="10MB" />
<param name="MaxBackupIndex" value="10" />
<param name="Append" value="true" />
<param name="Threshold" value="ERROR" />
<param name="file"
value="${catalina.home}/logs/myApp_1.log" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>
<appender name="file_2" class="org.apache.log4j.RollingFileAppender">
<param name="MaxFileSize" value="10MB" />
<param name="MaxBackupIndex" value="10" />
<param name="Append" value="true" />
<param name="Threshold" value="ALL" />
<param name="file"
value="${catalina.home}/logs/myApp_2.log" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>
<category name="org.springframework">
<priority value="ERROR" />
<appender-ref ref="file_1" />
</category>
<root>
<priority value="ERROR" />
<appender-ref ref="file_1" />
</root>
<logger name="test.messageHandler"
additivity="false">
<level value="ALL" />
<appender-ref ref="file_2" />
</logger>
</log4j:configuration>
根据配置文件myApp_1.log和myApp_2.log应在10MB之后滚动。
在我的情况下,日志正在滚动但随机大小
实施例:
myApp_1.log.1 size 8MB
myApp_1.log.2 size 12MB
etc.
与myApp_2.log文件相同
请在这里建议我做错了什么,日志应该在10MB之后发挥作用