Linux: Colored Logs

The boring black and white console logs can be lighten up using grc (grcat) or spc (supercat).

grc

Install grc:

emerge -av app-misc/grc

In /etc/syslog-ng/syslog-ng.conf configuration file, change the following statements:

#destination console_all { file("/dev/tty12"); };
destination console_all { program("grcat conf.log gt; /dev/tty12"); };

Restart the syslog-ng daemon and check the tty12.

supercat

Install supercat:

emerge -av app-misc/supercat

Create a new configuration file in /etc/supercat/spcrc-syslog and insert the following statements:

#  HTML COLOR NAME   COL A N T STRING or REGULAR EXPRESSION
#################### ### # # # ################################################################
Magenta              mag b     ([0-9]{1,3}(.[0-9]{1,3}){3})
Yellow               yel b     (`[^'`]*')
Yellow               yel b   s WARNING
Green                grn b     [[:space:]](/[^[:space:]&|;(){}]*)
Green                grn   1   (([^)]*))
Green                grn       (^...[ ]*[0-9]{1,2} [0-9]{2}:[0-9]{2}:[0-9]{2} )
Brown                yel       ^...[ ]*[0-9]{1,2} [0-9]{2}:[0-9]{2}:[0-9]{2} (w*)
Red                  red b     ^...[ ]*[0-9]{1,2} [0-9]{2}:[0-9]{2}:[0-9]{2} w* ([^ ]*):
Blue                 blu b     ^...[ ]*[0-9]{1,2} [0-9]{2}:[0-9]{2}:[0-9]{2} w* [^ []*([w*])

In /etc/syslog-ng/syslog-ng.conf configuration file, change the following statements:

#destination console_all { file("/dev/tty12"); };
destination console_all { program("spc -c /etc/supercat/syslog > /dev/tty12"); };

Restart the syslog-ng daemon and check the tty12.

supercat EXTENDED

The great advantage of supercat is while parsing any log file, you can apply colors to it. For instance:

tailf /var/log/messages | spc -c /etc/supercat/spcrc-syslog

abclinuxu.cz

Advertisements
This entry was posted in Linux, Security, Server and tagged , , , , , . Bookmark the permalink.