kassner / log-parser

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

how to use your parser in a web application? I cannot use it please provide some manual #32

Closed stevejohn82 closed 7 years ago

stevejohn82 commented 7 years ago

I want a web application like PIMP , and use your gut repository to parse my log files, please guide me how to use it, or provide some manual or instructions

stevejohn82 commented 7 years ago

I am getting error by using this code <?php require_once('vendor/autoload.php');

$parser = new \Kassner\LogParser\LogParser();

$lines = file('error.log.6', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach ($lines as $line) { $entry = $parser->parse($line); } echo $entry;

Error: "Uncaught exception 'Kassner\LogParser\FormatException' with message '2017-08-01T11:15:26.406692Z 0 [Note] Giving 0 client threads a chance to die gracefully' in /opt/lampp/htdocs/flat-ui-login/vendor/kassner/log-parser/src/Kassner/LogParser/LogParser.php:102 Stack trace: #"

kassner commented 7 years ago

@stevejohn82 as stated here, the library throws an Exception for each line that it couldn't parse, so you need to wrap it in a try/catch and adapt your logic around.