Closed SAH62 closed 1 year ago
%r
will be parsed using the request format METHOD URL HTTP/VERSION
, i.e.: POST /users/add HTTP/1.0
The line's request is MGLNDD_1.2.3.4_80
, which is an invalid HTTP request (hence why Nginx it responded with 400 Bad Request).
If you want a workaround to parse out those lines, check https://github.com/kassner/log-parser/issues/50#issuecomment-706707736.
Thanks!
I've set my parser to use the default Nginx format as described on the project README:
$parser->setFormat('%h %l %u %t "%r" %>s %O "%{Referer}i" \"%{User-Agent}i"');
A line in my nginx log is causing a format exception to be thrown:
PHP Fatal error: Uncaught Kassner\LogParser\FormatException: 162.243.142.22 - - [17/Feb/2023:02:50:10 -0500] "MGLNDD_1.2.3.4_80" 400 150 "-" "-" in /test/vendor/kassner/log-parser/src/LogParser.php:83 Stack trace:
0 /test/test.php(12): Kassner\LogParser\LogParser->parse()
1 {main}
thrown in /test/vendor/kassner/log-parser/src/LogParser.php on line 83
I don't see how this line fails to match the specified format. Am I missing something?