How to configure the access log in Tomcat

Home > Search > How-to

The $CATALINA_HOME/conf/server.xml file controls how events are written to the access log. By default, the server.xml file should have something similar to the following.

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
       prefix="localhost_access_log" suffix=".txt"
       pattern="%h %l %u %t &quot;%r&quot; %s %b" />


The above will create log files in the $CATALINA_HOME/logs/ directory. The log files will be named

Let's use a scenario where the Tomcat server has IP address and a client with IP address navigates to http://tomcat_hostname:8080 to get the Tomcat web interface. This will write the following events in the access log. The access log contains the IP address of the remote machine, the date and time a request was requested, the resource that was requested, and the status code. - - [07/Jul/2017:10:07:47 -0500] "GET / HTTP/1.1" 200 11256 - - [07/Jul/2017:10:07:47 -0500] "GET /tomcat.css HTTP/1.1" 200 5581 - - [07/Jul/2017:10:07:47 -0500] "GET /tomcat.png HTTP/1.1" 304 - - - [07/Jul/2017:10:07:47 -0500] "GET /bg-nav.png HTTP/1.1" 304 - - - [07/Jul/2017:10:07:47 -0500] "GET /asf-logo-wide.svg HTTP/1.1" 304 - - - [07/Jul/2017:10:07:47 -0500] "GET /bg-upper.png HTTP/1.1" 304 - - - [07/Jul/2017:10:07:47 -0500] "GET /bg-middle.png HTTP/1.1" 304 - - - [07/Jul/2017:10:07:47 -0500] "GET /bg-button.png HTTP/1.1" 304 - - - [07/Jul/2017:10:07:47 -0500] "GET /favicon.ico HTTP/1.1" 200 21630


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter in the box below so that we can be sure you are a human.