Difference between revisions of "Debug PHP Enabling slow log"
(Created page with "==Debugging PHP Scripts with slow_log== When working with php, you will notice that your site is taking longer to load then expected. Learning why your site is loading so slo...") |
(No difference)
|
Revision as of 18:43, 9 December 2013
Contents
Debugging PHP Scripts with slow_log
When working with php, you will notice that your site is taking longer to load then expected. Learning why your site is loading so slow would be great. You can do an strace but sometimes that information is not always the best to read.
Setup slow_log for PHP Scripts
You will need to edit the php-fpm pool configuration file.
vim /etc/php-fpm.d/www.conf
Now add or adjust the following lines to enable php slow log loading.
slowlog = /var/log/php5/slow.log request_slowlog_timeout = 5s
Setup PHP error log from your php-fpm Pool
You will also notice that some of the errors are now showing up in the error.log from the apache logs. You will also want to setup the php-fpm error log.
vim /etc/php-fpm.d/www.conf
Now add the following lines to enable php error log, this will over ride the default php error log lettings.
php_admin_value[error_log] = /var/log/php5/error.log php_admin_flag[log_errors] = on
Setup the PHP-FPM error log
PHP-FPM is a separate process and will need its own error log, which can also be setup in the php-fpm pool file.
vim /etc/php-fpm.d/www.conf
Now add the following lines to your configuration file
error_log = /var/log/php5/php-fpm-error.log
Now that everything is setup, you can view the logs by running the following command
tail -f /var/log/php5/*.log
Now you will want to restart php-fpm so the above changes are used.
service php-fpm restart
That will tail all the log files at once