Convert Apache logs from common to combined format

October 8, 2008 – 16:54

Here’s a nice post to convert Apache logs from the common to the combined format. AWstats needs the combined format to correctly parse the log files.

Overview of commands

1. find where combined start and common ends:

cat access.log | grep -n -m 1 "\\" \\""

2. split the file there:

csplit --prefix=access.log access.log numberfoundin1

3. Make common log into a combined log, with blank information for the referrer and user-agent

sed 's/$/ "-" "-"/' access.log00 > access.log00.fixed

4. combine old and fixed together

cat access.log00.fixed access.log01 > access.log.combined

Sorry, comments for this entry are closed at this time.