我在Windows服务器上有一个tomcat应用程序,并且使用Logback配置了应用程序日志-请参阅下面的logback.xml。 我的问题是日志翻转一次或两次,然后原始日志不断增长。
这是我的logback.xml配置文件:
<?xml version="1.0"?>
<configuration>
<property name="HOME_LOG" value="${catalina.home}/../../Logs/folder/Tomcat"/>
<appender name="fileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${HOME_LOG}/someName.log</file>
<encoder> <!-- class="ch.qos.logback.classic.encoder.PatternLayoutEncoder" -->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread]: %logger{50} - %msg%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${HOME_LOG}/archived/someName.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
<maxFileSize>20KB</maxFileSize>
<maxHistory>30</maxHistory>
<totalSizeCap>10GB</totalSizeCap>
<cleanHistoryOnStart>false</cleanHistoryOnStart>
</rollingPolicy>
</appender>
<appender name="eventReportsAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--file>${HOME_LOG}/eventsReport.log</file-->
<encoder> <!-- class="ch.qos.logback.classic.encoder.PatternLayoutEncoder" -->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread]: %logger{50} - %msg%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${HOME_LOG}/archived/eventsReport.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
<maxFileSize>20MB</maxFileSize>
<maxHistory>30</maxHistory>
<totalSizeCap>10GB</totalSizeCap>
<cleanHistoryOnStart>false</cleanHistoryOnStart>
</rollingPolicy>
</appender>
<logger name="com.mchange">
<level value="INFO"/>
</logger>
<root level="INFO">
<appender-ref ref="fileAppender"/>
<appender-ref ref="eventReportsAppender"/>
</root>
</configuration>
我认为问题在于应用程序服务正在锁定日志文件,并且无法将其重命名以进行过渡。 当我删除文件标签时,日志将被翻转,但命名包含我要避免的索引。