Administration toolsCentosCommandsDebianFedoraLinuxUbuntu

Colorize log files on CentOS and Ubuntu using ccze tool

ccze is a wonderful tool that brings real joy to the arduous task of reading or searching thru log files. It uses a modular approach to support custom colour formatting for popular applications such as Apache, Postfix, Exim, etc.

Install ccze on CentOS and Fedora linux

First enable Epel repository and run following command:

# yum install ccze -y

Install ccze on Debian/Ubuntu linux

On Debian/Ubuntu, you can use apt-get to install:

~$ sudo apt-get install ccze -y

How to use ccze tool

ccze colourises logs that are sent to standard out, for example, we can use tailf to follow a log file and then prettify the output by piping to ccze, examples:

~$ tail /var/log/syslog | ccze -A

Example using ccze tool
Example using ccze tool


Export log files to html file using ccze tool:

~$ cat /var/log/syslog | ccze -h > ~/Desktop/syslog.html

Example:

cczz export logfile in html
cczz export logfile in html

This tool comes with plenty of options. You can customize it more in these files

 /etc/cczerc, $HOME/.cczerc

To see list of plugins available just do

$ ccze -l

Example output:

~$ ccze -l
Available plugins:

Name      | Type    | Description
------------------------------------------------------------
apm       | Partial | Coloriser for APM sub-logs.
distcc    | Full    | Coloriser for distcc(1) logs.
dpkg      | Full    | Coloriser for dpkg logs.
exim      | Full    | Coloriser for exim logs.
fetchmail | Partial | Coloriser for fetchmail(1) sub-logs.
ftpstats  | Full    | Coloriser for ftpstats (pure-ftpd) logs.
httpd     | Full    | Coloriser for generic HTTPD access and error logs.
icecast   | Full    | Coloriser for Icecast(8) logs.
oops      | Full    | Coloriser for oops proxy logs.
php       | Full    | Coloriser for PHP logs.
postfix   | Partial | Coloriser for postfix(1) sub-logs.
procmail  | Full    | Coloriser for procmail(1) logs.
proftpd   | Full    | Coloriser for proftpd access and auth logs.
squid     | Full    | Coloriser for squid access, store and cache logs.
sulog     | Full    | Coloriser for su(1) logs.
super     | Full    | Coloriser for super(1) logs.
syslog    | Full    | Generic syslog(8) log coloriser.
ulogd     | Partial | Coloriser for ulogd sub-logs.
vsftpd    | Full    | Coloriser for vsftpd(8) logs.
xferlog   | Full    | Generic xferlog coloriser.

For more ccze optioins see man pages.

9 Comments

  1. You should check out lnav (http://lnav.org). It’s a log file viewer that does highlighting, follows files like ‘tail -f’, merges multiple files into a single view, filtering, and more.

  2. Brilliant, that’s really useful. Specially when you are digging into logs. Thanks a ton sire 🙂

  3. Thank you for sharing. I’d never heard of this tool, and trying it out on my CentOS 7 box, can’t believe I’ve lived so long without it.

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Check Also
Close
Back to top button