2

What is the reason why error_log() is not working after fastcgi_finish_request()?

Also any error thrown by PHP is not written to the log.

setup: ubuntu18.04 + nginx 1.15.6 + php7.2-fpm, the error log is written to /var/log/nginx/error.log

the_nuts
  • 5,634
  • 1
  • 36
  • 68

2 Answers2

1

This is not a bug, as stated in https://bugs.php.net/bug.php?id=80628

It's expected behavior.

To solve the "problem", there are two options:

  1. set PHP-FPM option "catch_workers_output" to "yes"
  2. set php.ini option "error_log" to log file path (preferably)
MattBianco
  • 1,501
  • 2
  • 20
  • 30
-2

As stated in the documentation:

This function flushes all response data to the client and finishes the request. This allows for time consuming tasks to be performed without leaving the connection to the client open.

So by finishing the request I assume no code after it will be executed like with die()

Code Spirit
  • 3,992
  • 4
  • 23
  • 34