使用ccze工具在Linux上着色日志文件

  不知道大家有没有这种感受,在一片白茫茫的日志输出中,查看和阅读起来非常痛苦,你有没有想过,如果日志有颜色是否就会方便阅读一点,正巧我也是这样想的,聪明的人都是这样想的(允许我自恋一下)。
  ccze一个用C语言编写的快速日志着色器,使日志查找更加方便快捷,它使用模块化方法来支持流行应用程序(如ApachePostfixExim等)或自定义颜色格式。

在CentOS和Fedora linux上安装ccze
1
# yum install ccze -y
在Debian / Ubuntu linux上安装ccze
1
2
〜$ sudo apt-get install ccze -y

使用ccze工具
  • 控制台查看

  ccze colourises发送到标准的日志,例如,我们可以使用tailf来跟踪一个日志文件,然后通过管道输出来美化输出到ccze,例如:

1
〜$ tail /var/log/syslog | ccze -A

  • 使用ccze工具将日志文件导出到html文件:

    1
    〜$ cat /var/log/syslog | ccze -h > /home/syslog.html

  • 列出ccze模块:

1
2
$ ccze -l

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
~$ ccze -l

Available plugins:

Name | Type | Description
------------------------------------------------------------
apm | Partial | Coloriser for APM sub-logs. #部分| 用于APM子日志的着色器。
distcc | Full | Coloriser for distcc(1) logs. #完整| 用于distcc(1)日志的着色器。
dpkg | Full | Coloriser for dpkg logs. #完整| dpkg日志的着色器。
exim | Full | Coloriser for exim logs. #完整| 进出口日志的着色剂。
fetchmail | Partial | Coloriser for fetchmail(1) sub-logs. #部分| 用于fetchmail的着色器(1)子日志。
ftpstats | Full | Coloriser for ftpstats (pure-ftpd) logs. #完整| ftpstats(pure-ftpd)日志的着色器。
httpd | Full | Coloriser for generic HTTPD access and error logs. #完整| 用于通用HTTPD访问和错误日​​志的着色器。
icecast | Full | Coloriser for Icecast(8) logs. #完整| 用于Icecast(8)日志的着色剂。
oops | Full | Coloriser for oops proxy logs. #完整| oops代理日志的着色器。
php | Full | Coloriser for PHP logs. #完整| PHP日志的着色器。
postfix | Partial | Coloriser for postfix(1) sub-logs. #部分| 用于后缀(1)子日志的着色器。
procmail | Full | Coloriser for procmail(1) logs. #完整| procmail(1)日志的着色器。
proftpd | Full | Coloriser for proftpd access and auth logs. #完整| 用于proftpd访问和auth日志的着色器。
squid | Full | Coloriser for squid access, store and cache logs. #完整| 用于鱿鱼访问,存储和缓存日志的着色器。
sulog | Full | Coloriser for su(1) logs. #完整| su(1)原木的着色剂。
super | Full | Coloriser for super(1) logs. #完整| 超级(1)原木的着色剂。
syslog | Full | Generic syslog(8) log coloriser. #完整| 通用系统日志(8)日志着色器。
ulogd | Partial | Coloriser for ulogd sub-logs. #部分| ulogd子日志的着色器。
vsftpd | Full | Coloriser for vsftpd(8) logs. #完整| vsftpd(8)日志的着色器。
xferlog | Full | Generic xferlog coloriser. #完整| 通用xferlog着色器。
  • 这个工具有很多选项,我们可以在这些文件中进行更多的自定义
    1
    ~$ vim /etc/cczerc 

简书:对Request.parameter中参数进行添加或修改

使用ccze工具在Linux上着色日志文件

https://pingfangushi.com/posts/8a49e8dd/

作者

SanLi

发布于

2018-01-28

更新于

2021-07-08

许可协议