I have got this regex pattern that works with my current apache log format:
preg_match("/^(\S+) (\S+) (\S+) \[([^:]+):(\d+:\d+:\d+) ([^\]]+)\] \"(\S+) (.*?) (\S+)\" (\S+) (\S+) (\".*?\") (\".*?\")$/", $line, $matches); // pattern to format the line
It works with this log:
127.0.0.1 - - [19/Jun/2012:11:38:37 +0200] "GET /some_page HTTP/1.1" 200 8243 "http://example.com/referrer" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5"
Now I have changed the apache log format to include the server name, so the new log would be:
127.0.0.1 - - [19/Jun/2012:11:38:37 +0200] **servername.com** "GET /some_page HTTP/1.1" 200 8243 "http://example.com/referrer" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5"
The only thing it does it's adding servername.com before the "GET /url...".
Now the regex doesn't work anymore and I don't know what do I have to modify to make it match the new log format.