php開啓慢日誌

默認是以本機的安裝路徑php

cd /usr/local/php/etc/web

vim php-fpm.confvim

; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
slowlog = log/pool.log.slow   //能夠修改慢日誌的路徑

; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
request_slowlog_timeout = 1   //慢日誌超時的時間

不過目錄須要手動建立,否則重啓php-fpm將會出錯curl

mkdir /usr/local/php/log函數

 

php-fpm慢日誌的例子,慢日誌會記錄下進程號,腳本名稱,具體哪一個文件哪行代碼的哪一個函數執行時間過長。php-fpm

 

查看慢日誌文件  tail -10f  pool.log.showurl

[19-Sep-2014 11:34:12]  [pool www] pid 2957
script_filename = /data/wwwroot/cms.91.com/webroot/mobile91.php
[0x00000000030c6c10] request_by_curl() /data/wwwroot/cms.91.com/webroot/mobile91.php:207
[0x00000000030c6190] request_by_curl() /data/wwwroot/cms.91.com/webroot/mobile91.php:189

[19-Sep-2014 11:34:47]  [pool www] pid 2968
script_filename = /data/wwwroot/cms.91.com/webroot/mobile91.php
[0x000000000300b840] request_by_curl() /data/wwwroot/cms.91.com/webroot/mobile91.php:206
[0x000000000300adc0] request_by_curl() /data/wwwroot/cms.91.com/webroot/mobile91.php:189
相關文章
相關標籤/搜索