Enabling access logs in Spring Boot

This post will show how to enable access logs in spring boot. To enable tomcat access logs in Spring boot project we have to add following properties in application.properties file.

server.tomcat.accesslog.pattern="%h %l %u %t '%r' %s %b %D"
server.tomcat.accesslog.directory=/var/log
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.file-date-format=.yyyy-MM-dd
server.tomcat.accesslog.prefix=accessLogHostName
server.tomcat.accesslog.suffix=_access.log
server.tomcat.accesslog.rotate=false
server.tomcat.accesslog.rename-on-rotate=true

This will start spitting access logs in file /var/log directory. You can also change the pattern of the logging in pattern property.

If you have any queries or suggestions please let me know in comments.

Leave a Comment

Your email address will not be published. Required fields are marked *