Closed mariobernheim closed 3 years ago
Unfortunately this library won't be able to parse this kind of request, given it's an invalid request in terms of HTTP. You can still do some workaround if you wish, something like $parser->addPattern('%r', '(?P<request>.+)');
, but given that's an invalid request, you won't be able to parse much out of it.
Ran this:
<?php $loader = require __DIR__ . '/vendor/autoload.php'; $parser = new \Kassner\LogParser\LogParser(); $parser->setFormat('%h %l %u %t "%r" %>s %O "%{Referer}i" \"%{User-Agent}i"'); $lines = file('/var/log/nginx/access.log', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach ($lines as $line) { $entry = $parser->parse($line); } ?>
and got this:
`#0 /home/xxx/analiticas/analytics.php(7): Kassner\LogParser\LogParser->parse('xxx.xxx.xxx.xxx -...')
1 {main}
thrown in /home/v/xxx/vendor/kassner/log-parser/src/LogParser.php on line 82 [29-Sep-2020 19:12:06 America/New_York] PHP Fatal error: Uncaught Kassner\LogParser\FormatException: xxx.xxx.xxx.xxx - - [29/Sep/2020:04:37:17 -0400] "\x03\x00\x00/*\xE0\x00\x00\x00\x00\x00Cookie: mstshash=Administr" 400 157 "-" "-" "-" in /home/xxx/axxx/vendor/kassner/log-parser/src/LogParser.php:82 Stack trace:
0 /home/xxx/analiticas/analytics.php(7): Kassner\LogParser\LogParser->parse('xxx.xxx.xxx.xxx -...')
1 {main}
thrown in /home/xxx/analiticas/vendor/kassner/log-parser/src/LogParser.php on line 82 `