Apache logfile colorizer


This simple script reads loglines in Apaches „combined“ format from STDIN, and prints relevant data nicely colored to the terminal. This script is very nice to watch whats going on on your website.

 m/(\S+?) (\S+?) (\S+?) \[(.+?)\] "\S+? (\S+?) HTTP\S+?" (\d*?) (\d*?) "(.*?)" "(.*?)"/;
 print $red;
 print "$1 ";     # IP
 print $green;
 print "$6 ";     # Status
 print $yellow;
 print "$5 ";     # Request
 print $cyan;
 print "$8 ";     # Referrer
 print $magenta;
 print "$9 ";     # Browser
 print $white;
 print "\n";

Example Usage:

$> tail -f /var/log/apache/access.log | ./livelog.pl