I have a spring boot application. The access log of embedded tomcat is configured to rotate daily with time stamp suffix in application.properties. My requirement is to generate the rotated log file into an archive folder. but I could not find any configuration to specify the location for rotated file in application.properties. Does anyone know how achieve this?
all the latest log will be in /logs folder and all the rotated log file should be in /logs/archive folder. - How to do this?
OK, finally i figured out a way to do this using logback access.
Include the following dependency
<dependency>
<groupId>net.rakugakibox.spring.boot</groupId>
<artifactId>logback-access-spring-boot-starter</artifactId>
<version>2.7.0</version>
</dependency>
Also create a logback-access.xml in resources folder with following configuration.
<configuration>
<property resource="application.properties" />
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/dev_access.log</file>
<rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/Archive/dev_access_%d{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%h %l %u %t "%r" %s %b %D</pattern>
</encoder>
</appender>
<appender-ref ref="FILE" />
</configuration>