parsing - php log-parser outputs error with undefined function -


i trying log-parser working https://github.com/kassner/log-parser , on first trial errors ->

code:

<?php  $parser = new \kassner\logparser\logparser.php();  $lines = file('/var/log/apache24/error.log', file_ignore_new_lines | file_skip_empty_lines); foreach ($lines $line) {     $entry = $parser->parse($line); } echo $entry; ?> 

error output:

fatal error: call undefined function php() in /usr/home/www/parselog.php on line 3 

how logparser class output correctly?

read documentation linked in question, see class loaded namespace, should not use .php extension when loading logparser class. so, have remove .php third line:

$parser = new \kassner\logparser\logparser(); 

see php documentation importing namespaces.


it worked me. installed dependency composer:

composer require kassner/log-parser:~1.0 

and used code in log.php file:

<?php require_once('vendor/autoload.php');  $parser = new \kassner\logparser\logparser();  $lines = file('/var/log/apache2/access.log', file_ignore_new_lines | file_skip_empty_lines); foreach ($lines $line) {     $entry = $parser->parse($line); } echo $entry; 

then executed it:

php -f log.php 

it throws error:

php fatal error: uncaught exception 'kassner\logparser\formatexception' message '127.0.0.1 - - [01/apr/2015:00:32:01 +0200] "get /... http/1.1" 200 1753 "-" "mozilla/5.0 ... firefox/35.0"' in /.../vendor/kassner/log-parser/src/kassner/logparser/logparser.php:73

the error format of access.log file, logparser class loaded.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -