Tail your Logs with a Touch of Color
Article posted by Joel Moss on 20 Apr 2010   |  

Eric Lubow (@elubow), a colleague of mine just released his first Ruby Gem and published it on Codaset, and I gotta say, it's a pretty damn useful one too.

ColorTail - or ColourTail if you want the correct english spelling - is a very easy way to give your log files a touch of color when you tail them. Tailing logs can be very useful, but can also be very confusing, and sometimes a touch mind blowing with all the data that some logs can spew out at you. So adding a bit of color, or underlining certain lines, or even flashing them would really help you identify the important bits of your log.

Just install ColorTail:

  # sudo gem install colortail

Then create a file in your home directory called .colortailrc, and define your colortail config:

Groupings = {
  # This default matching scheme
  'default' => [
      { :match => /Completed in/,    :color => :red,     :attribute => :reverse },
      { :match => /EMERGENCY/,    :color => :red,     :attribute => :reverse },
      { :match => /FATAL/,        :color => :red,     :attribute => :bright },
      { :match => /CRITICAL/,     :color => :red },
      { :match => /DEBUG/,        :color => :green },
      { :match => /ERROR/,        :color => :green },
      { :match => /INFO/,         :color => :none },
      { :match => /WARN/,         :color => :yellow }
  ]
}

The above is the default, so will apply to all logs whenever you tail them with the colortail command, like so:

  # colortail -g log/development.log

Which will give you this:

Check out the project, and enjoy!

This site contains the musings of Joel Moss, and is powered by Codaset pages; a simple, yet powerful way to host your static site. Just commit and push your site to your free Git repository at Codaset, and that's it!

Tell me more about Joel »