How to parse Amazon S3 log format in php

//How to parse Amazon S3 log format in php

How to parse Amazon S3 log format in php

Hi there,

If you want to parse / split the items in the Amazon S3 logformat in php, you need some regular expression magic.

Here is my snippet
Based on a array of the linies in the logfile

foreach ($LogEntries as $logEntry)
{
$items = explode(" ",$logEntry);
echo "<pre>".$logEntry."</pre><br />";
preg_match('/(\S+) (\S+) \[(.*?)\] (\S+) (\S+) (\S+) (\S+) (\S+) "([^"]+)" (\S+) (\S+) (\S+) (\S+) (\S+) (\S+) "([^"]+)" "([^"]+)"/', $logEntry, $matches);
var_dump($matches);
}

/Renzo

By | 2011-04-22T21:28:49+00:00 July 9th, 2010|Linux|0 Comments

Leave A Comment