'TTL for .log.gz files in container? [Spring-Boot]
I've started out with spring-boot project recently & I'm not able to figure out the time to live for log.gz files generated from spring-boot code.
I have an idea of how Rolling Policy works for the transition of .log files to .log.fz files, but not able to understand how long the .log.gz files are stored in the container (note: no ttl setting on the container.)
Please help & thanks in advance!
Solution 1:[1]
you are looking for a configuring a RollingFileAppender, you can use log4j addind the dependency
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
adding in the logging file the rollingOut policy and rules by creating a custom appender
<appender name="roll-by-size" class="org.apache.log4j.rolling.RollingFileAppender">
<rollingPolicy class="org.apache.log4j.rolling.FixedWindowRollingPolicy">
<param name="ActiveFileName" value="target/log4j/roll-by-size/app.log" />
<param name="FileNamePattern" value="target/log4j/roll-by-size/app.%i.log.gz" />
<param name="MinIndex" value="7" />
<param name="MaxIndex" value="17" />
</rollingPolicy>
<triggeringPolicy class="org.apache.log4j.rolling.SizeBasedTriggeringPolicy">
<param name="MaxFileSize" value="5120" />
</triggeringPolicy>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %m%n" />
</layout>
this will add automatic compression
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ionut Adrian Ene |
