38

I sometimes monitor apache and php error logs using tail under FreeBSD. Is there any way to get colorized output, either using tail or some other command line app?

Alternatively, what is your favorite way to monitor the various web-related logs in realtime?

Ian
  • 1,488
  • 4
  • 26
  • 32

8 Answers8

31

Generic Colouriser (grc):

enter image description here

Works with many different file formats.

Example:

grc tail -f /var/log/apache/access.log /var/log/apache/error.log

Multitail:

alt text

Works with even more file formats :) And is more of a full blown "tail" with multi windows, diff outputs etc.. Very useful.

Examples:

Merge 2 logfiles in one window:

multitail /var/log/apache/access.log -I /var/log/apache/error.log

In one window show all new TCP connections and their state changes using netstat while in the other window displaying the merged access and error logfiles of apache

multitail -R 2 -l "netstat -t" /var/log/apache/access.log -I /var/log/apache/error.log
Mike Pennington
  • 8,266
  • 9
  • 41
  • 86
rkthkr
  • 8,503
  • 26
  • 38
20

Check out CCZE, it does the job for me. You have a choice of curses, ansi and html output.

Taz
  • 115
  • 5
Coops
  • 5,967
  • 1
  • 31
  • 52
4

Monitor '/applications' highlighted;

tail -f /var/log/system.log | grep /Applications --color
HBruijn
  • 72,524
  • 21
  • 127
  • 192
mowarren
  • 71
  • 2
3

Check out glTail (http://www.fudgie.org/). Does way more than you're asking, but maybe that's OK

2

Colorize is very good tool for simply piping your text through another filter to get fancy ANSI colors. In fact, it's one simple 4kB perl script (almost half of it is just documentation) and it's based on regular expressions.

You can highlight whole line containing given patern (good for hiding unwanted debug logs or highlighting Exceptions) or just highlight pattern in uncolored line (highlighting http response codes).

I have several presets for various file types in separate runnable files. Then I just run mvn clear install | colorbuild, tail -f *.log* | colorlog or svn diff | colordif to have really fancy output.

andrej
  • 463
  • 4
  • 12
  • available at https://web.archive.org/web/20080321072656/http://www.flinkmann.de/colorize-pl.71.1.html – andrej Feb 13 '14 at 15:40
0

I wrote TxtStyle, a small utility for colorising logs. You define regular expressions to highlight in ~/.txts.conf file:

[Style="example"]
!red: regex("error")
green: regex("\d{4}-\d\d-\d\d")
# ...

And then apply the styles:

txts -n example example.log

or you can also pipe the output

tail -f example.log | txts -n example

enter image description here

armandino
  • 141
  • 4
0

You might want to try histring, lets you color most of the outputs with simple ANSI codes http://www.freebsdsoftware.org/misc/histring.html

Ryan Coates
  • 156
  • 4
0

On FreeBSD use colorize. and add in .tailrc:

#!/bin/sh
/usr/bin/tail "$@" | /usr/local/bin/colorize
kasperd
  • 29,894
  • 16
  • 72
  • 122