如何实现apache记录请求响应时间日志


本文摘自PHP中文网,作者V,侵删。

具体步骤如下所示:

(相关推荐:apache教程)

找到apache配置文件

1

2

3

4

5

6

netstat -nap | grep 80

# 找到对应端口进程 31114

tcp6       0      0 :::4430                 :::*                    LISTEN      31114/httpd

ps auxf | grep 31114

# 找到对应apache的进程命令中的配置文件*.conf的路径,到指定路径修改配置文件,例如

vim httpd.conf

修改指定端口下的VirtualHost

1

2

3

4

5

6

<VirtualHost 80>

.......

CustomLog "/var/prof.log" "[%a]%{%F %T}t id=%{APIIndex}i time=%D(us) url=%U%q"

</VirtualHost>

 

指令: CustomLog "/var/prof.log" "[%a]%{%F %T}t id=%{APIIndex}i time=%D(us) url=%U%q"

%D - 官方解释:Time taken to process the request, in millis,处理请求的时间,以微秒为单位
%T - 官方解释:Time taken to process the request, in seconds,处理请求的时间,以秒为单位
%{ms}T - 官方解释:Time taken to commit the response, in millis,提交响应的时间,以毫秒为单位

修改后重启apache,观察日志输出数据如下:

1

2

3

4

[200.200.222.95]2019-03-04 15:39:32 id=- time=100107(us) url=/apps/secvisual/home/home/on_dev_manage

[200.200.222.95]2019-03-04 15:39:38 id=- time=106476(us) url=/apps/secvisual/home/home/on_dev_manage

[200.200.222.95]2019-03-04 15:39:43 id=- time=101263(us) url=/apps/secvisual/home/home/on_dev_manage

[200.200.222.95]2019-03-04 15:39:48 id=- time=101333(us) url=/apps/secvisual/home/home/on_dev_manage

以上就是如何实现apache记录请求响应时间日志的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

linux中mysql日志在哪

怎么重启Apache服务呢

如何通过Apache实现跳转功能

httpd和Apache区别

如何卸载Apache2

centos如何卸载Apache

Apache做什么的

php如何与Apache连接超时

Apache nginx优缺点

django和Apache的区别

更多相关阅读请进入《Apache》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...