I've encountered a strange behaviour. I'm running NGINX with PHP-FPM.
When I enable the PHP error log in php.ini:
error_log = /var/www/logs/php-scripts.error.log
log_errors = on
the error log is written to as expected:
...
[15-Feb-2017 19:35:28 Etc/UTC] PHP Parse error: syntax error, unexpected end of file, expecting ',' or ';' in /var/www/html/index.php on line 7
However, at the same time the error log configured in my NGINX vhost is not written to at all (this is the NGINX configuration fragment):
server {
listen 80;
server_name vhost.com;
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log; <- this is always empty
}
Now to my surprise, when I disable the error log in php.ini:
; error_log = /var/www/logs/php-scripts.error.log <-- commented out
log_errors = on
the NGINX error log is written to:
...
2017/02/16 12:01:44 [error] 13#13: *27 FastCGI sent in stderr: "PHP message: PHP Parse error: syntax error, unexpected end of file, expecting ',' or ';' in /var/www/html/index.php on line 7" while reading response header from upstream, client: 172.19.0.2, server: domain.com, request: "GET / HTTP/1.1", upstream: "fastcgi://172.19.0.3:9000", host: "domain.com:8080"
I do not understand this behavior at all. What's the source of this interference between the two logging systems? Why can't I have the error log enabled in php.ini and at the same time have NGINX's error log being written to? At the moment it's either one or another. Is it possible to overcome this issue?