If a page takes over a couple of seconds to process, I’d like Apache to log that URL somewhere. Is this possible? I have a lot of sites, so I was looking for an automatic way to do this as opposed to proprietary code for each site.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Take a look at http://httpd.apache.org/docs/2.2/mod/mod_log_config.html. You can setup a custom log that includes the time it took to serve the request.
For example:
Would add the time in microseconds it took to serve the request as the last field of your logfile.
You would add that line to your httpd.conf, then in each virtualhost where you want to use it, add this line:
You could also create a new LogFormat that contains only exactly what you want, maybe like this:
In your virtualhost, you can have multiple logs, so you could have:
All that said, there’s a huge caveat. This will measure only the time it takes the server to serve the page. It will not include the time it takes to execute any javascript in the browser. If you need to measure javascript execution time, you’ll need to use a tool like firebug.
Once you’ve got the log, you could use something like apachelog to parse the logfile to get only the requests that took longer than whatever threshold you want to use.
I’m not sure if it’s possible to log only the long requests and bypss the parsing step. It might be, but i have a feeling it would take a significant amount of work.