Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Monitoring apache logs with tail –f tends gets very frustrating for the eyes after a while. Are there any tool/options to colorize the log outputs? Maybe signal FATAL with red, etc...

share|improve this question
up vote 9 down vote accepted

I'm using multitail to monitor logs, it includes coloring as well as multiple logfile monitoring either merged or in windows. Give it a try.

share|improve this answer

Any reason why you can't use something like this:

tail -f FILE | grep --color=always KEYWORD


share|improve this answer
Did you test it? IT doesn't output anything for me. – SabreWolfy Nov 12 '13 at 11:22
This filters the output as well, so any line without KEYWORD will be ignored. – Michal Mau Apr 3 '15 at 17:41
The OP seems to be implying he's looking for a keyword or words. Unless the file is multiline in nature (which apache logs generally are not), then this answer is sufficient. – Garrett May 27 '15 at 5:50

Found this:

tail -f file | perl -pe 's/keyword/\e[1;31;43m$&\e[0m/g'

This only works on ANSI terminals, but all others have become virtually extinct. \e[...m ist the ANSI escape sequence SGR "select graphic rendition". The "..." can be replaced by some semicolon-separated integers, with the meaning:

0 : all attributes off 1 : bold 31 : foreground red 43 : background yellow

"keyword", of course, can be any perl regular expression:

(foo|bar) highlight the strings foo and bar \b((foo|bar)\b highlight the words foo and bar .\b((foo|bar)\b. highlight the whole line that contains the words foo or bar

Or, the easy way, just install colortail Its probably in your favorite repo (dag for CentOS)

share|improve this answer
Yeah, multitail is best – Grizly Sep 3 '10 at 5:25

I use a small script with grep combinations to get some colors:

shopt -s expand_aliases

alias grey-grep="GREP_COLOR='1;30' grep -E --color=always --line-buffered"
alias red-grep="GREP_COLOR='1;31' grep -E --color=always --line-buffered"
alias green-grep="GREP_COLOR='1;32' grep -E --color=always --line-buffered"
alias yellow-grep="GREP_COLOR='1;33' grep -E --color=always --line-buffered"
alias cyan-grep="GREP_COLOR='1;36' grep -E --color=always --line-buffered"

tail -1000f /var/log/apache2/error.log | grey-grep ".*PerformanceLogger.*|$" | cyan-grep "INFO|$" | yellow-grep "WARN|$" | red-grep "[ERROR].*|[FATAL].*|$" | green-grep "***|$"

The point is that every chained grep add a different color. So the result is something like: Apache log with some colors

share|improve this answer

Shameless plug: I wrote a tool called TxtStyle that does something similar as the options mentioned earlier. You can run it as follows:

tail -f /var/log/syslog | txts --regex '\d+'

You can also define named styles in the config file (~/.txts.conf) and use it like so:

ifconfig | txts --name ifconfig

(ifconfig style is defined out of the box)

share|improve this answer

There's one feature that I haven't seen in those colorizers -- highlight response times (higher time -> more alarming color). 256-color support in modern terminal emulators could be useful here.

share|improve this answer

Another useful grep trick to show all output but colour the selected KEYWORD is : tail -f FILE | grep --color=always -E "$|REGEXP"

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.