当前位置: 代码网 > 服务器>服务器>Linux > 如何实现apache记录请求响应时间日志

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

2025年03月30日 Linux 我要评论
具体步骤如下所示:(相关推荐:apache教程)找到apache配置文件netstat -nap | grep 80# 找到对应端口进程 31114tcp6       0      0 :::443

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

具体步骤如下所示:

(相关推荐:apache教程)

找到apache配置文件

netstat -nap | grep 80
# 找到对应端口进程 31114
tcp6       0      0 :::4430                 :::*                    listen      31114/httpd
ps auxf | grep 31114
# 找到对应apache的进程命令中的配置文件*.conf的路径,到指定路径修改配置文件,例如
vim httpd.conf
登录后复制

修改指定端口下的virtualhost

<virtualhost>
.......
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,观察日志输出数据如下:

[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记录请求响应时间日志的详细内容,更多请关注代码网其它相关文章!

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com