Friday, June 10, 2011

Power of AccessLog & Tomcat Valve configuration

In recent past we faced quite a performance issues resulting in different modes of collecting performance statistics from web server. One of the handy tool was web server access logs, all I had to do is configure my webserver to write access logs. It dumps all the requested information (URL, Timestamp & Even roundtrip/response time of a request), How cool... with zero additional code you get response time of each request.

Link below details of access log configuration on tomcat, this could vary depending on the type of webserver used. But every webserver would have a access log by default.

All different types of valves supported by Tomcat, most useful of it all is "Request Dumper" valve (dumps all request detail) & "Access Log" Valve.

Example, below configuration (%D %T) will log response time for a request & timestamp of the request.

Valve className="org.apache.catalina.valves.AccessLogValve" prefix="localhost_access_log." suffix=".txt" pattern="%D %T"

Lot of tools can help you analyze the access logs & provide more insight of the usage response time etc.

Conclusion: We all know it's mandatory for a web server to have an access log,
but the good part is this can greatly ease performance study & tune
your web application.

No comments: