To monitor who is using your server, set up HTTP access logging in
Tomcat. Every request that comes to Tomcat gets a
Setting up Logging
To setup access logging, edit the Tomcat server configuration file, ${tomcat_home}/conf/server.xml
and uncomment the AccessLogValve
:
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>
By default the log files are created in the ${tomcat_home}/logs
directory and roll over to a new file at midnight.
The log messages can be written in either of two standard web access
log formats by setting the pattern attribute to common
or combined
.
These appear to be the ones used by web log analyseres. Other log
formats can be specified with the pattern attribute.
More information on the AccessLogValve and the pattern attribute can
be found on the Tomcat
Valve Configuration Reference
.
Modifying the Log Format
We can extend the "common" and "combined" patterns by appending the
response time for each request. To use this, set the
The FastCommonAccessLogValve
has better performance
than the AccessLogValve
. If you are running a
production system, you might consider switching to the FastCommonAccessLogValve
.
The main restriction is that only the "common" and "combined" log
formats can be used.