Wednesday, July 17, 2013

Parsing an Apache log and splitting the output into different files

Working on a project at work debugging why some requests end up with a 503 HTTP status code, I needed to split up apache logs so that I could parse them with GnuPlot.

This snippet will read multiple apache logfiles, filter out everything except status codes and the timestamp, and then split the output into different files depending on what status code it is.