Skip to content

Instantly share code, notes, and snippets.

@adamv
Created November 4, 2010 22:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save adamv/663328 to your computer and use it in GitHub Desktop.
Save adamv/663328 to your computer and use it in GitHub Desktop.
Colorize access_log
#!/bin/bash
# Escaped color codes
BLACK=`echo -e '\033[0;30m'`
DK_GREY=`echo -e '\033[1;30m'`
RED=`echo -e '\033[0;31m'`
PINK=`echo -e '\033[1;31m'`
GREEN=`echo -e '\033[0;32m'`
LT_GREEN=`echo -e '\033[1;32m'`
BROWN=`echo -e '\033[0;33m'`
YELLOW=`echo -e '\033[1;33m'`
BLUE=`echo -e '\033[0;34m'`
LT_BLUE=`echo -e '\033[1;34m'`
PURPLE=`echo -e '\033[0;35m'`
LT_PURPLE=`echo -e '\033[1;35m'`
CYAN=`echo -e '\033[0;36m'`
LT_CYAN=`echo -e '\033[1;36m'`
LT_GREY=`echo -e '\033[0;37m'`
WHITE=`echo -e '\033[1;37m'`
COLOR_NONE=`echo -e '\033[0m'`
tail -f /var/log/httpd/access_log | sed \
-e "/GET \/favicon.ico/d" \
-e "s/^.* 40[012356789] .*$/$PINK&$COLOR_NONE/" \
-e "s/^.* 404 .*$/$BROWN&$COLOR_NONE/" \
-e "s/^.* 500 .*$/$PURPLE&$COLOR_NONE/"
@adamv
Copy link
Author

adamv commented Nov 4, 2010

  • Ignore favicon.ico; it is boring.
  • Highlight 40x errors...
  • ...except highlight 404 errors different.
  • 500 errors are even more special.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment