Search code examples
spring-bootembedded-tomcat-8

Serving log files from Spring Boot's embedded Tomcat


I'm looking to have my log files available to an admin without needing to ssh to the host.

Hopefully something easy as http://myhost:myport/logs/app.log .

Is there any way to expose an endpoint using Spring Boot that would serve my log files?


Solution

  • Spring Boot Actuator

    Add the following dependency to your application:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    

    And out of the box you'll get a lot of useful endpoints including: /logfile

    No additional configuration necessary.