Log-php-fpm Slow log query

Source: Internet
Author: User
Tags php error php error log php script system log

Project with PHP development, in the production process, it should be a period of time to monitor the PHP script running state, which PHP process is too slow, what error logs. Q: How do I see a PHP script that is slow to detect? answer: View php-fpm slow log.
1. Find the configuration file storage address first
Find/-name php-fpm.conf


Vi/usr/servers/php/etc/php-fpm.conf


Open to see if your slow log is turned on, or where the slow log that is turned on is stored. The corresponding address will be replaced by your own.
2. If you do not turn on slow log query, first turn on
The default request_slowlog_timeout is 0,php the slow script log is off, so set to n greater than 0, which means that scripts that execute more than n are logged into the slowlog. then monitor the site when there is a problem when viewing the next Slowlog can find slow script, the script to check processing.
Request_slowlog_timeout and Slowlog need to be set simultaneously,Open the request_slowlog_timeout while you need to turn on Slowlog,slow log paths need to be created manually
Remove the request_slowlog_timeout, slowlog prefix semicolon '; ' Set Request_slowlog_timeout =1;:wq    //Save exit Create slow Log directory Mkdir-p/var/logdata/php-fpm/php-fpm-slowlog.logkillall php-fpm /USR/SERVERS/PHP/SBIN/PHP-FPM//Restart PHP-FPM


3. Find the slow log storage address




4. Observe slow log Messages
Tailf/var/logdata/php-fpm/php-fpm-slowlog.log



When on , if a script executes for more than the specified time, a message similar to the following is written to the specified log file:
[19-dec-2016 16:54:49] [Pool www] pid 18575script_filename =/home/web/htdocs/sandbox_canglong/test/tt.php[0x0000000003a00dc8] curl_exec ()/ HOME/WEB/HTDOCS/SANDBOX_CANGLONG/TEST/TT.PHP:2[0X0000000003A00CD0] Exfilter_curl_get ()/home/web/htdocs/sandbox_ Canglong/test/tt.php:6

Log Description:Script_filename is a portal filecurl_exec (): Description is the time at which this method was executed. exfilter_curl_get (): Description The method to call Curl_exec () is Exfilter_curl_get (). the number following the colon of each line is the line number.

when turned on, there are also related records in the error log file. as follows:
[19-dec-2016 15:55:37] WARNING: [Pool www] child 18575, script '/home/web/htdocs/sandbox_canglong/test/tt.php ' (Request: "get/test/tt.php") Executing too slow (1.006222 sec), logging[19-dec-2016 15:55:37] notice:child 18575 stopped for tracing[19-dec-2016 15:55 : PNs] notice:about to trace 18575[19-dec-2016 15:55:37] notice:finished trace of 18575


System Log: Record system related information:http://blog.csdn.net/ty_hf/article/details/55511624Apache access logs and error logs:http://blog.csdn.net/ty_hf/article/details/55504719nginx access log and error log:http://blog.csdn.net/ty_hf/article/details/55518070php-fpm Slow Log:Detect slow PHP Script execution:http://blog.csdn.net/ty_hf/article/details/55504172PHP error Log: Detects PHP runtime or user self-logging error log:http://blog.csdn.net/ty_hf/article/details/55505262MySQL Slow log: Log SQL that affects performance in the MySQL server:http://blog.csdn.net/ty_hf/article/details/55504172
This address: http://blog.csdn.net/ty_hf/article/details/55504172

Log-php-fpm Slow log query

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.