Search code examples
logginglogbacktemporary-files

LogBack generating weird files :/


I like LogBack, seriously I do!

I configured it in a way that most of the times produces log files with the following structure:

+ logs
    - latestRun.log
    + rolled
      - logFile_2012-03-09T03.log 
      - logFile_2012-03-09T04.log
      - etc...

The structure above makes me very happy! (Sometimes the content does not but this is another issue)

Occasionally, I end up with files like this though:

+ logs
    - latestRun.log
    - latestRun.log1998071534195169.tmp
    - latestRun.log2016071527094180.tmp
    - etc...
    + rolled
      - logFile_2012-03-09T03.log 
      - logFile_2012-03-09T04.log
      - etc...

Now those .tmp files are a pain in the neck and I really cannot explain why they are generated. The issue seems to be more frequent when I add the .gz in the <fileNamePattern> for compressing the rolled files.

This is how my appender is configured in my logback.xml file:

<property name="LOGS_FOLDER" value="logs/" />

<appender name="ROLLINGFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${LOGS_FOLDER}latestRun.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <!-- daily rollover -->
        <fileNamePattern>${LOGS_FOLDER}rolled/logFile_%d{yyyy-MM-dd'T'HH}.log.gz</fileNamePattern>
        <!-- keep 30 days' worth of history -->
        <maxHistory>30</maxHistory>
    </rollingPolicy>

    <encoder>
        <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
    </encoder>
</appender>

The environment is Linux Ubuntu


Solution

  • Looks like an incarnation of LBCORE-169 bug. We can only vote and wait...