Apache-style access logs for Tomcat

To get an Apache-style access log, complete with referrers and user-agents, I created a directory called /var/log/tomcat writable by the Tomcat process, and I added the following to tomcat/conf/context.xml:

<Valve className=”org.apache.catalina.valves.FastCommonAccessLogValve”
pattern=”combined”
directory=”/var/log/tomcat”
prefix=”access.log”
rotatable=”false” />

This will create a file called /var/log/tomcat/access.log and start logging requests to it. I’m turning off Tomcat’s date stamping and log rotation, since I prefer to use logrotate.

One thought on “Apache-style access logs for Tomcat”

  1. Tomcat 7 does not support
    org.apache.catalina.valves.FastCommonAccessLogValve
    change it to
    org.apache.catalina.valves.AccessLogValve

    FastCommonAccessLogValve was deprecated in Tomcat 6 and is completely
    removed from Tomcat 7.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">