Error log parser written in PHP
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LogReader
.gitignore
LICENSE
README.md
example_apache.php
example_nginx.php

README.md

LogReader

This is error log parser written in PHP. It reads nginx errors and errors of PHP module for Apache. You can use it if you need to read and analyze web server's error log.

Usage

Apache

require_once 'LogReader/ApachePhp.php';
require_once 'LogReader/Storage/Array.php';

$logReader = new LogReader_ApachePhp("/var/log/apache2/error.log", new LogReader_Storage_Array());
$logReader->read();

$logs = $logReader->getStorage()->load();
//or $logs = $logReader->getStorage()->loadUnique();
$logs = array_reverse($logs);
var_dump($logs);

Each item of $logs contains: timestamp, type, message. See example_apache.php.

Nginx

require_once 'LogReader/Nginx.php';
require_once 'LogReader/Storage/Array.php';

$logReader = new LogReader_Nginx("/var/log/nginx/error.log", new LogReader_Storage_Array());
$logReader->read();

$logs = $logReader->getStorage()->load();
//or $logs = $logReader->getStorage()->loadUnique();
$logs = array_reverse($logs);
var_dump($logs);

Each item of $logs contains: timestamp, type, message, host, request. See example_nginx.php.