We have Tomcat instance running on Ubuntu server. It runs a web service, open to the internet.

Sometimes it has a sudden spike of traffic and goes down. There is nothing unusual in Tomcat access logs. I guess it is because some of the requests are so 'heavy' that they never finish and hence are not recorded to Tomcat access logs.

Is there a way to configure Tomcat to log incoming requests before they are executed? Each request should be logged in the following format

Date, Time, URL (with query string params), IP address (of client)

There should be one line per request. Only incoming requests to ports 80 and 443 should be logged.


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.

  • -1 for the AccessLogValve - I confirmed it only logs after the request is completed, either buffered or not. But +1 for the reverse proxy idea.
    – kubanczyk
    Nov 8 '15 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.