英文:
slf4j logback log rolling creating .tmp file
问题
我有一个问题,有时日志滚动会创建一个.tmp文件,并且不会创建原始的日志文件。有趣的是,我注意到这种情况发生在日志滚动在午夜前1分钟开始时。
<slf4j.version>1.7.15</slf4j.version>
我的logback.xml配置如下:
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${COMPONENT_LOGDIR}/abc.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${COMPONENT_LOGDIR}/abc.log.%d{yyyy-MM-dd}.%i.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>750MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>10</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${logPatternMdc}</pattern>
</encoder>
</appender>
英文:
I have a issue where sometime log rolling creating a .tmp file and does not create the original log file back. interesting I noticed this happens when rolling of logs start 1 min before the midnight.
<slf4j.version>1.7.15</slf4j.version>
my logback.xml configuration is as below
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${COMPONENT_LOGDIR}/abc.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${COMPONENT_LOGDIR}/abc.log.%d{yyyy-MM-dd}.%i.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>750MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>10</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${logPatternMdc}</pattern>
</encoder>
</appender>
答案1
得分: 0
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${COMPONENT_LOGDIR}/otm-rest.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${COMPONENT_LOGDIR}/otm-rest.log.%d{yyyy-MM-dd}.%i.gz</fileNamePattern>
<maxFileSize>750MB</maxFileSize>
<maxHistory>30</maxHistory>
<totalSizeCap>15GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>${logPatternMdc}</pattern>
</encoder>
</appender>
英文:
Using different rolling policy seemed to have fixed the issue. please refer to working config below:
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${COMPONENT_LOGDIR}/otm-rest.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${COMPONENT_LOGDIR}/otm-rest.log.%d{yyyy-MM-dd}.%i.gz</fileNamePattern>
<maxFileSize>750MB</maxFileSize>
<maxHistory>30</maxHistory>
<totalSizeCap>15GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>${logPatternMdc}</pattern>
</encoder>
</appender>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论