首頁  >  文章  >  運維  >  如何實作apache記錄請求回應時間日誌

如何實作apache記錄請求回應時間日誌

王林
王林轉載
2020-12-14 16:38:524694瀏覽

如何實作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


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


指令: 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記錄請求回應時間日誌的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:csdn.net。如有侵權,請聯絡admin@php.cn刪除