kassner / log-parser

PHP Web Server Log Parser Library
Apache License 2.0
339 stars 64 forks source link

May be can support Nginx error.log? #42

Closed awebc closed 4 years ago

awebc commented 4 years ago

How to set nginx error.log format ?

kassner commented 4 years ago

From the README:

# default Nginx format:
$parser->setFormat('%h %l %u %t "%r" %>s %O "%{Referer}i" \"%{User-Agent}i"');

You can customize the format as you wish, but using Nginx's log_format way of writing is not supported. You should be able to find alternatives for most of the options.

The format is based on Apache's: https://httpd.apache.org/docs/2.4/en/mod/mod_log_config.html#formats

kassner commented 4 years ago

Ah, my bad, I read that too fast.

As noted in #21 and #34, parsing the error.log is not the goal of this project.

Given how structured it can become (specially when PHP errors are piped to this file), you'll have to write a custom stream just to get each log entry, given they can be multiline.