Friday 11 March 2011

HOW-TO: Enable logs in tomcat

When you install tomcat 6 from Ubuntu's repository, it does not write the access log automatically. To enable logging uncomment the following line in /usr/share/tomcat6/conf/server.xml

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>

Save the changes and restart tomcat:

$ /etc/init.d/tomcat6 restart

The logs will be stored in /usr/share/tomcat6/logs/ directory which is a symbolic link to  /var/log/tomcat6/ directory.