NGINX is not showing PHP 500 error log (nor does php-fpm)


I received a 500-error on my API request to a PHP backend. The result was returned as a 500 html status.

When searching the logs, there was no mention of this 500 error, other than in the access log of nginx.

Where does nginx or php-fpm put the backtrace of PHP errors?


Turns out, you need to enable catch_workers_output = yes in your www.conf file, typically located over at /etc/php/7.4/fpm/pool.d/

# file /etc/php/7.4/fpm/pool.d/www.conf
catch_workers_output = yes

The comments above that line explains it pretty well:

; Redirect worker stdout and stderr into main error log. If not set,
; stdout and stderr will be redirected to /dev/null according to
; FastCGI specs.
; Note: on highloaded environement, this can cause some delay in
; the page process time (several ms).
; Default Value: no