Spring boot - How to specify different location for rotated tomcat log file

mac :

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?

mac :
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>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to specify a profile when deploying a Spring boot war file to Tomcat?

Java Spring - How to use classpath to specify a file location?

spring-boot-logger.log file location for deployed spring boot app

spring boot log to file

How to do logging in Spring boot for different log level in different files

How to specify Tomcat logs as home for log4j log file

How to log particular classes to another log file in Spring Boot

Spring Boot: How to specify the PasswordEncoder?

spring-boot default log location

How to set file location in application properties - Spring boot

How to specify external location for image store in Spring Boot 2.0 web app?

How to run external war file with embedded tomcat of spring boot with gradle?

How can I programmatically supply the keystore file with Spring Boot and Tomcat?

Different Log files for different package:Spring Boot

How to specify logging.config when multiple Spring Boot Apps are deployed on tomcat

How to log the real client IP on embedded Tomcat access log on Spring Boot application with Nginx as reverse proxy?

Spring Boot: Use different Tomcat Version

How to roll log file daily in spring-boot application

How to clear log file before executing spring boot app?

How to exclude error log level in a file logback spring boot

How to write a stdout statement in a .log file in spring boot application

How to log soap request and response with custom messages to file in Spring Boot?

How to specify schema location in an xsd file?

Jenkins & Java : How to specify input file location

How can I change the default location of log4j2.xml in Java Spring Boot?

How to log INFO into one file and ERROR into another file using log4j in spring boot.

How to log the number of available/used threads in a spring boot (tomcat) based application?

How to specify prefix for all controllers in Spring Boot?

How do I specify a BeanNamingStrategy with Spring Boot?