luqo33
luqo33

Reputation: 8361

PHP not logging script errors in spite of php.ini settings

I'm using PHP-FPM with NGINX and I cannot get error log to work correctly with PHP-FPM.

This is my php.ini, the relevant part:

error_reporting = 'E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE'
error_log = /var/www/logs/php-scripts.error.log
log_errors = 'On'
display_errors = 'Off'
display_startup_errors = 'Off'
html_errors =  'Off'

open_basedir = /var/www/html/:/var/www/.tmp/:/var/www/logs/
upload_tmp_dir = /var/www/.tmp

Relevant fragments of www-pool.comf (config loaded by PHP-FPM master process):

listen = 9000
user = www-data
group = www-data
request_slowlog_timeout = 10
slowlog = /var/log/php-fpm/$pool.slow.log
chdir = /var/www/html
access.log = /var/log/php-fpm/$pool.access.log
catch_workers_output = Yes

/var/www/logs/ is writable by www-data - the user PHP-FPM and the web server is running as.

Now if I do this in index.php:

error_log('Some error');

The error message finds its way to /var/www/logs/php-scripts.error.log without problems. However when I try to trigger the error like so:

trigger_error('Some error', E_USER_WARNING);

The error is not recorded in the log file. Also, when I launch intentionally broken PHP script, I get a 500 Internal Server Error on the screen, but nothing is logged to the PHP error log whatsoever, e.g.:

// index.php
<?php
echo 'Trigger error'

Notice the missing ; above - that should report an error in the error log, I'm only getting 500 Internal Server Error and no output in the log.

Will you ba able to assist? Thanks.

Upvotes: 4

Views: 703

Answers (1)

ablopez
ablopez

Reputation: 850

Remove the quotes from error_reporting, and the other settings as well, your php.ini should look like this:

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE
error_log = /var/www/logs/php-scripts.error.log
log_errors = On
display_errors = Off
display_startup_errors = Off
html_errors =  Off

open_basedir = /var/www/html/:/var/www/.tmp/:/var/www/logs/
upload_tmp_dir = /var/www/.tmp

Upvotes: 1

Related Questions