How to configure Tomcat to log requests before they are executed?-Collection of common programming errors

Tomcat’s AccessLogValve has the buffered configuration option which defaults to true, which means that if Tomcat crashes, you might lose the buffer’s worth of logs. See http://tomcat.apache.org/tomcat-7.0-doc/config/valve.html#Access_Log_Valve.

You might want to try and set buffered to false, which would then make the valve flush the log on every request, bearing in mind that this will probably affect overall performance.

Another option is to place e.g. an Apache reverse proxy in front of Tomcat (using mod_proxy, mod_jk, mod_ajp or mod_cluster) and have it do the request logging.