I am trying to persist the logs of a Spring Boot Application, however, since the logs generated are large I am trying to use the logback.xml to roll the file greater than 350MB into a compressed file.
I am able to roll a couple of MB's per day but midway the service starts writing to a temp file. I have tried both "TimeBasedRollingPolicy" and "Size AndTimeBasedRollingPolicy" with Triggering Policy of "SizeAndTimeBasedFNATP" but the results are unchanged. The .tmp files are generated every time.
My Logback.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/home/xyz/logs/ProdLog.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/home/xyz/logs/log_%d{yyyy-MM-dd}_%i.log.zip</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 350MB -->
<maxFileSize>350MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>5</maxHistory>
<!--<maxFileSize>350MB</maxFileSize>-->
</rollingPolicy>
<encoder>
<pattern>%date [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
<root level="INFO">
<appender-ref ref="FILE"/>
<appender-ref ref="STDOUT"/>
</root>
</configuration>
I see that the ticket for logback .tmp file issue is marked closed on Jira. Could someone help with what needs to be modified here to avoid generating the temp files?