Time for action – translating the referer logs to a human-readable format
We can translate a referer log to a human-readable format by using the command line utility awk
. We can convert the entire referer.log
file to a human-readable format by using the following command sequence:
$ cat referer.log | awk '{printf("%s ", strftime("%d/%b/%Y:%H:%M:%S",$1)); print $2 " " $3 " " $4;}' > referer_human_readable.log
The log messages from referer.log
, as shown, should look like the following messages after conversion:
12/Sep/2010:01:36:06 127.0.0.1 http://en.wikipedia.org/wiki/Main_Page http://en.wikiquote.org/ 12/Sep/2010:01:36:12 127.0.0.1 http://en.wikiquote.org/wiki/Main_Page http://upload.wikimedia.org/wikiquote/en/b/bc/Wiki.png
The command we saw before works fine for the conversion of the entire log file, but is not useful if we want to see the live referer log with human-readable timestamps. For achieving this, we can use the following command:
$ tail -f referer.log | awk '{printf("%s...