Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP-FPM with dedicated error log file

Tags:

php

logging

I've set up an Apache2/PHP-FPM site and would like PHP-FPM's errors to be logged to its own error log file. However, with the current configuration, the errors are being logged to /var/log/php5-fpm.log in the following format:

WARNING: [pool www] child 22926 said into stderr: "NOTICE: PHP message: PHP Parse error:  syntax error, unexpected 'if' (T_IF) in /var/www/site.com/error.php on line 1"

In my /etc/php5/fpm/pool.d/www.conf I have the following options:

php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on
catch_workers_output = yes

When I disable catch_workers_output, the error logging ceases completely. However, in phpinfo() output, it is showing the logfile I specify in the configuration.

Why is PHP5-FPM not respecting this logfile. Is there any way to have errors for the fpm pool logged in a separate file?

My php version:

# php5-fpm  -v
PHP 5.4.9-4~precise+1 (fpm-fcgi) (built: Nov 30 2012 10:48:01)

Thank you for any information!

like image 865
Dan Avatar asked Jan 15 '13 18:01

Dan


1 Answers

You'll find the error_log = /var/log/php-fpm.log in your main FPM Configuration. Based on your example you are setting this in a Pool configuration, which will only work for that specific pool/domain.

like image 67
Diemuzi Avatar answered Oct 05 '22 10:10

Diemuzi