Skip to content

trianglman/ApacheLogParser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apache Log Parser Reader

About the parser

These classes are designed to take an access log from Apache and convert it into a PHP object that can then be used to populate a database or parsed further.

Installing

Download the source from Github

git clone git://github.com/trianglman/ApacheLogParser.git

There are only two files necessary for the parsing: apacheLogFile.php and apacheLogRecord.php. Copy those into your source code or your PHP include path and include both files.

Usage

The primary class you’ll need to work with is \ApacheLogParser\ApacheLogFile. To prepare the parser call it’s constructor with the contents of the log file as the first argument and the CustomLog format it was created with.

$logFile = new \ApacheLogParser\ApacheLogFile($fileContents,
                                            '%h %l %u %t \\"%r\\" %>s %b');

You can then retrieve an array of all the log entries or an individual record with the getRow() function.

//gets the full set of records
$records = $logFile->getRow();

//gets just the first record
$firstAccess = $logFile->getRow(0);
About the author

John Judy is a software developer who has been working with PHP since 2001. He has worked for a number of e-commerce websites and currently works for a court transcription and legal document service and retrieval firm.

About

A robust apache access log parser built in PHP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published