admin管理员组

文章数量:1346676

Logback is creating .tmp files during log rotation, and they are not being deleted even after the retention period.

These .tmp files can be generated for various reasons, but the goal is to ensure they are automatically removed after log rotation or at a later stage.

Using logback 1.2.10 version.

Below is the .tmp file and logback configuration.

-rw-rw----+ 1 root root 121 Mar 1 00:00 /var/log/cli/cli_2025-02-28.0.log372862483201017.tmp

     `<appender name="CliAppender"
            class="ch.qos.logback.core.rolling.RollingFileAppender">
            <file>/var/log/cli/cli.log</file>
            <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
             <fileNamePattern>/var/log/cli/cli_%d{yyyy-MM-dd}.%i.log.gz
                    </fileNamePattern>
                            <maxFileSize>50MB</maxFileSize>
                    <!-- keep 30 days' worth of history -->
                    <maxHistory>30</maxHistory>
            </rollingPolicy>

            <encoder>
                    <charset>UTF-8</charset>
                    <pattern>%d{"yyyy-MM-dd'T'HH:mm:ss,SSSXXX"} [%thread] %-5level %msg%n
                    </pattern>
            </encoder>
    </appender> `       

本文标签: loggingLogback Fails to Delete tmp Files After Log RotationStack Overflow