kassner / log-parser

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

Apache 2.4.7 log format #18

Closed scott-davidjones closed 7 years ago

scott-davidjones commented 8 years ago

Hi,

I am trying to read an apache log in the following format:

127.0.0.1 - - [11/Jan/2016:18:30:16 +1300] "GET / HTTP/1.1" 403 505 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/47.0.2526.73 Chrome/47.0.2526.73 Safari/537.36"

I am using the following format:

$parser->setFormat('%h - - %t "%r" %s %b "-" "%{User-Agent}i"');

I have also tried:

$parser->setFormat('%h %l %u %t "%r" %s %b "%{Referer}i" \"%{User-Agent}i"');

but each time i get the format exception error. Any chance you can help me on this? I have tried setting no parser (so as to use the default) but no luck there either.

scott-davidjones commented 8 years ago

ok turns out using the nginx formatter worked instead..

adamgriffin93 commented 7 years ago

@scott-davidjones

How did you get this working? I tried using the default but no luck.

scott-davidjones commented 7 years ago

@adamgriffin93 from what i can remember (no longer have access to that code) i used the setFormat function to use the nginx log format and it picked it up.