loggingnginxhhvmhiphop

How do you format the HHVM error log output?


I'm using HHVM with Nginx.

I like to have a certain error log format. Specifically, with timestamp and error level with timezone offset included in error logs like:

 [2014-02-23 01:20:33 -0500] WARNING: File not found

I've managed to get timestamps into the HHVM error log with the following:

 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.log.header = true

However, I can't find any way to format the error log output. Currently, here is what I get for output in the HHVM error log:

 [Wed Feb 25 18:08:20 2015] [hphp] [6516:7f30a15ff700:4:000001] [] \nWarning: File not found:

Does anyone know how to modify the error log format for HHVM?


Solution

  • This is currently hardcoded in hhvm's source.

    I highly recommend submitting a feature request to the hhvm team, they're a bunch of very helpful people.

    If you're not interested in that, you could pretty easily edit the timestamp call to include the offset, then rearrange the snprintf() lines to match your liking. The function you're looking for is the line starting with std::string Logger::GetHeader() { -- which is currently line 222.

    Aside from that, you could have a cron or background process ( i.e. something like tail -f /var/log/some/error.log |awk -F " " '{ print $1 $5 }' >> /var/log/other/error.log & ) parse the log into the format of your liking

    I realize of course, that these options while functional, are probably not ideal.