2017-03-07 123 views
1

我試圖調試一個可能需要很長時間才能運行的php腳本,並返回'504 Gateway Time-out'(在nginx上運行fastcgi-php5-fpm,使用ubuntu官方軟件包安裝)。php error_log消息在超時時丟失

發生超時時 - php error_log消息不會記錄到error.log文件。

如何調試腳本 - 或者至少從腳本獲取任何日誌?

我試着調用flush(),它只是將stdout刷到客戶端瀏覽器,而不是stdlog到日誌文件。

一個簡單的腳本來演示情況:

error.php:

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

編輯:

Finnaly我已經寫了日誌,使用

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

但它不能解決問題 - 當php終止時,error_log不會寫入fo r超時。

回答

0

最後我已經寫了日誌,使用

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

一個文件,但它不解決問題的問題 - 當PHP終止超時error_log中沒有寫入。