Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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.

share|improve this answer
    
Thank you for the reverse proxy idea! –  Maxim Eliseev Jul 3 '13 at 9:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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