有没有办法让Apache日志缓慢的请求? [英] Is there a way to have Apache log slow requests?

查看:114
本文介绍了有没有办法让Apache日志缓慢的请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果一个页面接管一个几秒钟的过程,我想Apache来记录某个地方该URL。这可能吗?我有很多的网站,所以我一直在寻找一种自动的方式来做到这一点,而不是专有code为每个站点。

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.

推荐答案

在看看<一个href=\"http://httpd.apache.org/docs/2.2/mod/mod_log_config.html\">http://httpd.apache.org/docs/2.2/mod/mod_log_config.html.你可以设置,其中包括花了服务请求的时间。自定义日志

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.

例如:

LogFormat "%h %l %u %t \"%r\" %>s %b %D" common-time

将添加时间微秒花费的服务请求,作为你的日志文件的最后一个字段。

Would add the time in microseconds it took to serve the request as the last field of your logfile.

您会该行添加到您的httpd.conf文件,然后在要使用它的每个虚拟主机,添加此行:

You would add that line to your httpd.conf, then in each virtualhost where you want to use it, add this line:

CustomLog logs/access_log_time common-time

您还可以创建一个只包含正是你想要的一个新的LogFormat,也许是这样的:

You could also create a new LogFormat that contains only exactly what you want, maybe like this:

LogFormat "\"%r\" %D" measure-time

在你的虚拟主机,你可以有多个日志,所以你可以有:

In your virtualhost, you can have multiple logs, so you could have:

CustomLog logs/access_log common
CustomLog logs/access_log_time measure-time

所有这一切说,有一个巨大的警告。这将只测量需要服务器提供的页面的时间。它的不会包含它需要在浏览器中执行任何JavaScript的时间。如果你需要测量JavaScript的执行时间,你需要使用一个工具,如萤火虫

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.

一旦你得到了日志,你可以使用类似 apachelog 来分析日志文件来获得只花了请求比你想使用的任何阈值。

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.

我不知道是否有可能只记录从长远要求和bypss解析一步。这可能是,但我有一种感觉,它会采取工作显著量。

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.

这篇关于有没有办法让Apache日志缓慢的请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆