Try out multitail. This is an übergeneralization of tail -f
. You can watch multiple files in separate windows, highlight lines based on their content, and more.
multitail -c /path/to/log
The colors are configurable. If the default color scheme doesn't work for you, write your own in the config file. For example, call multitail -cS amir_log /path/to/log
with the following ~/.multitailrc
:
colorscheme:amir_log
cs_re:green:INFO
cs_re:red:SEVERE
Another solution, if you're on a server where it's inconvenient to install non-standard tools, is to combine tail -f
with sed or awk to add color selection control sequences. This requires tail -f
to flush its standard output without delay even when its standard output is a pipe, I don't know if all implementations do this.
tail -f /path/to/log | awk '
/INFO/ {print "\033[32m" $0 "\033[39m"}
/SEVERE/ {print "\033[31m" $0 "\033[39m"}
'
or with sed
tail -f /path/to/log | sed --unbuffered \
-e 's/\(.*INFO.*\)/\o033[32m\1\o033[39m/' \
-e 's/\(.*SEVERE.*\)/\o033[31m\1\o033[39m/'
If your sed isn't GNU sed, replace \o033
by a literal escape character and remove --unbuffered
.
Yet another possibility is to run tail -f
in an Emacs shell buffer and use Emacs's syntax coloring abilities.
You have to set vim in the non compatible mode, so it doesn't behave like vi. You should switch syntax on and switch on filetype detection and plugin detection. Here is a minimal .vimrc you can try:
set nocp
syntax on
filetype plugin indent on
This will make vim behave somewhat nicer and give syntax coloring. But there are a lot more things you could change.
You should install something like pathogen or vundle, so you can easily install new syntax files and other scripts.
Best Answer
You can write a multithread plugin to change the buffer(s) in real time in Python or any other script that Vim supports and has threads.
But this only works in terminal as far as I know. At least in X11, the GUI version will crash if the GUI is modified by another thread.
If you accept other programs, grc and ccze are able to colorize streams.