Search code examples
phploggingnginxtimeoutfastcgi

php error_log messages lost upon timeout


I am trying to debug a php script who might take long time to run, and return '504 Gateway Time-out' (running on nginx with fastcgi-php5-fpm, installed using ubuntu official packages).

When timeout occur - php error_log messages do not get logged to the error.log file.

How can I debug the script - or at least get any logs from the script?

I tried to call flush(), it just flushing stdout to the client browser, not stdlog to the log file.

a simple script to demonstrate the situation:

error.php:

<?php
error_log("error occured!");
while(true){}
?>

EDIT:

Finnaly i've wrote the logs to a file using

file_put_contents($filename, $message.'\n', FILE_APPEND);

but it do not solve the problem in question - error_log is not written when php terminated for timeout.


Solution

  • Finally i've wrote the logs to a file using

    file_put_contents($filename, $message.'\n', FILE_APPEND);
    

    but it do not solve the problem in question - error_log is not written when php terminated for timeout.