Snippet: watching multiple logs & ignore & color

Tail lets you watch multiple logs by simply specifying them one after annother.  I use:

tail -f /var/log/httpd/access_log -f /var/log/httpd/error_log -f /var/log/php_errors.log -f /var/www/html/simms/var/log/system.log

This can be quite noisy so I like to filter secondary files from the access_log.  To do this I simply pipe it to egrep Like the following:

tail -f ... | egrep -v "(\.gif|\.jpg|\.png|\.swf|\.ico|\.txt|\.xml|\.css|\.js)"

If you are on AWS behind the ELB you might have health check traffic noise, so I add the following:

tail -f ... | egrep -v ... | egrep -v "ELB\-HealthChecker"

Then I like to easily see errors so I pipe everything through some sed replacements:

tail -f ... | egrep -v ... | sed -e 's/error/\x1b[31m&\x1b[0m/'

You also may find it useful to identify redirects, 404, or when the Google bot is leaching content:

tail -f ... | egrep -v ... | sed -e 's/error/\x1b[31m&\x1b[0m/' -e 's/302/\x1b[32m&\x1b[0m/' -e 's/404/\x1b[31m&\x1b[0m/' -e 's/Googlebot/\x1b[31m&\x1b[0m/'

… did I mention I use a global snipit/clipboard manager called AceText?  You may use a different app, if you do let me know in the comments, I wouldn’t mind seeing what else is out there.

Advertisements
Snippet: watching multiple logs & ignore & color

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s