Dark theme | Light theme

February 4, 2009

Enable access logging in Tomcat

Tomcat can log our requests to the server in a log file. This way we can see which pages are invoked, from which IP address and more. To enable request logging We need to open conf/server.xml of our Tomcat instance. We then look for a Valve element where the className attribute has the value org.apache.catalina.valves.AccessLogValve. Probably this element is enclosed in a XML comment. We need to remove the comment so Tomcat can recognize the element. We save the server.xml file and start Tomcat. In the logs directory we get the logfile localhost_common_access_log.2009-02-04.txt. And this file contains all requests made to Tomcat.