2017-03-07 118 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中没有写入。