Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring boot tomcat access logs

Tags:

spring-boot

I enabled tomcat access logs as per the spring boot reference documentation. But its not working properly. When I enabled it, access log file got created and I can see requests being logged there for that day. But at the start of the next day I don't see any new file. It started logging at 21hrs. Third day it started logging from 02hrs. From 4th day no access logs created.

Here are the properties that I used.

server.tomcat.access-log-enabled=true
server.tomcat.access-log-pattern=%h %l %u %t "%r" %s %b %D
server.tomcat.basedir=/var/lib/org_name/tracking_server 

under tracking_server folder logs and work folder got created.

Please let me know if I'm missing something. Regular logging is working perfectly according to the configuration specified in logback.xml

Thanks for your help in advance.

like image 931
user3626166 Avatar asked May 11 '14 18:05

user3626166


People also ask

How do I view Tomcat logs?

The main Apache Tomcat configuration file is at /opt/bitnami/tomcat/conf/server. xml. Once Apache Tomcat starts, it will create several log files in the /opt/bitnami/tomcat/logs directory.

Where can I find server logs Tomcat?

By default, the Tomcat HTTP Access Logs are stored in the dotserver/tomcat-X.x/logs/ folder within the dotCMS distribution, and the files are named dotcms_access. YYYY-MM-DD. log, where the YYYY-MM-DD in the file name is replaced by the date of the log file.

Where are spring boot application logs?

Java. Now we simply need to run the application and hit http://localhost:8080/log to see the log messages.


1 Answers

That configuration works for me in spring boot version 1.2.3.RELEASE. However, if you have the current version of spring boot, those parameters are a little bit different, reference here:

server.tomcat.accesslog.directory=logs # Directory in which log files are created. Can be relative to the tomcat base dir or absolute. server.tomcat.accesslog.enabled=false # Enable access log. server.tomcat.accesslog.pattern=common # Format pattern for access logs. 

As you note, the difference is the hyphen (-).

Additionally, tomcat access log configuration include the following parameters, according to this document:

  • fileDateFormat. Default value is yyyy-MM-dd. It means that the log file is going to change daily. If you change for yyyy-MM-dd.HH, the log is going to change hourly.
  • rotatable. Default value is true. If you set to false, I understood that it is going to have just only file. it do not use fileDateFormat parameter.

However, in my version of spring boot (1.2.3.RELEASE) the class org.springframework.boot.autoconfigure.web.ServerProperties there are no values to change those properties (Tomcat subclass). But if you check org.apache.catalina.valves.AccessLogValve you could change this properties:

/**  * Should we rotate our log file? Default is true (like old behavior)  */ protected boolean rotatable = true;  /**  * Date format to place in log file name.  */ protected String fileDateFormat = ".yyyy-MM-dd"; 

I know maybe you should play with those parameters. I hope this post help to solve your problem.

like image 157
jmgoyesc Avatar answered Sep 25 '22 06:09

jmgoyesc