Apache 记录请求响应时间日志

找到apache配置文件

netstat -nap | grep 80
# 找到对应端口进程 31114
tcp6       0      0 :::4430                 :::*                    LISTEN      31114/httpd
ps auxf | grep 31114
# 找到对应apache的进程命令中的配置文件*.conf的路径,到指定路径修改配置文件,例如
vim httpd.conf
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

修改指定端口下的VirtualHost

<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"
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

%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
posted @   GaoYanbing  阅读(772)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示