Tomcat access logs are not enabled in Spring Boot by default. The access logs can be a very useful troubleshooting tool. The logs can be enabled by adding a property to the application.properties in the src/main/resources directory.
# Enable access log. server.tomcat.accesslog.enabled=true
This will enable Tomcat Access Logging. The logs will go to the current temporary directory where the existing Tomcat work directory is located. The logs will appear under a directory named logs in a file that follows the normal Tomcat Access logs, such as access_log.2019-02-04.log.
It is a good idea to specify the directory that you want to contain the Tomcat logs, etc instead of relying on them being sent to a temporary directory. You can specify the Tomcat Basedir by adding the following to the application.properties.
# Tomcat base directory, which will be at the same level as the # Spring Boot jar. If not specified, a temporary directory # is used. server.tomcat.basedir=tomcat
The directory with the specified name will be created at the same directory level as the .jar that contains the Spring Boot application. If you are running the application as part of your IDE, then the specified directory will appear in the root of your source code.
An alternative way to specify the properties is to specify them as JVM parameters. An example of both of these would be
Tomcat Access Logs can be easily enabled in a Spring Boot application by setting the appropriate property. This allows easy troubleshooting and if you set the Tomcat basedir, you can also access Tomcat’s work directory.
Additional information about configuring Spring Boot Tomcat can be found at https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-configure-accesslogs
sheltonn February 5th, 2019
Posted In: Javaninja