Home > Spring > Spring Boot > Enable the access logs in Spring Boot for embedded tomcat server

Enable the access logs in Spring Boot for embedded tomcat server

Access logs contains the information about the request received and response sent to the client. It contains all the important data which are required to analyze the type of request coming to the application.

Below are the steps which is required to configure the tomcat access logs for the Spring Boot application.

Settings in application.properties file

# Base directory of the access log.

# Enable access log.

# Format pattern for access logs.
server.tomcat.accesslog.pattern=%t %a "%r" %s (%D ms) "%{User-Agent}i" "app-vr-@project.version@" 

# Whether to buffer output such that it is flushed only periodically.

# Directory in which log files are created. Can be absolute or relative to the Tomcat base dir.

# Date format to place in the log file name.

# Log file name prefix.

# Whether to enable access log rotation.

# Whether to defer inclusion of the date stamp in the file name until rotate time.

# Log file name suffix.

These are the common properties files settings which will enable the access log feature in your spring boot application with all set of relevant information.

You can find all supported properties for embedded server’s access logs in this official spring doc reference page.