我正在运行HHVM 3.1.0和nginx。我设置为将HHVM中的错误发送到它自己的日志文件,而不是通过nginx返回它们。我注意到的一件事是错误没有列出任何类型的时间戳或日期/时间,只是错误的字符串,这里有一些例子:
\nWarning: Invalid argument: function: not a valid callback array in /srv/http/nx/app/model/Session.php on line 57
\nFatal error: Failed to initialize storage module: user (path: ) in /srv/http/nx/app/model/Session.php on line 57
\nWarning: Invalid argument: function: not a valid callback array
有没有办法更好地格式化这些错误日志条目以使其更有用?至少要显示日期和时间?有没有办法通过nginx
传回错误,以php-fpm
的方式记录错误?以下是使用php-fpm并在/var/log/nginx/error.log
中获取错误的示例(注意好的格式):
[04-Aug-2014 13:53:55 UTC] PHP Warning: Invalid argument supplied for foreach() in /srv/http/nx/app/controller/website/SEOFinds.php on line 164
作为参考,这里是/etc/hhvm/php.ini
; php options
pid = /var/run/hhvm/pid
date.timezone="America/New_York"
; hhvm specific
hhvm.server.file_socket=/var/run/hhvm/hhvm.sock
;hhvm.server.port = 9000
hhvm.server.type = fastcgi
hhvm.server.default_document = index.php
hhvm.log.level = Warning
hhvm.log.always_log_unhandled_exceptions = true
hhvm.log.runtime_error_reporting_level = 8191
hhvm.log.use_log_file = true
hhvm.log.file = /var/log/hhvm/error.log
hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc
hhvm.mysql.typed_results = false
hhvm.eval.jit_warmup_requests = 0
下面是我的nginx位置块:
location ~ \.php$ {
fastcgi_buffer_size 128k;
fastcgi_buffers 128 16k;
fastcgi_pass unix:/var/run/hhvm/hhvm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
答案 0 :(得分:3)
时间戳由hhvm.log.header
INI设置控制。如果将其设置为true
,您将在日志中获得时间戳。