The output of journalctl really looks messy without colors. Is it possible to add colors to its output? On my system it seems only important lines are highlighted. Even dmesg can output with color by adding the --color switch!
- 1,012
7 Answers
Install ccze, then use it like this:
journalctl -b -k -f | ccze [-A] [-o nolookups]
explanation:
-A, --raw-ansi
If one wants to enable raw ANSI color sequences instead of using curses, this option does just that.
-o, --options OPTIONS...
However, lookups is an option that might be better to disable. When on, ccze will try to look up usernames, service
names, and lots of other stuff, which will slow down coloring a great deal. If one is piping a long log through ccze,
this option might be turned off [nolookups] to speed up the process.
- 125
- 4
- 189
The color support of journalctl is documented in man journalctl:
When outputting to a tty, lines are colored according to priority: lines of level ERROR and higher are colored red; lines of level NOTICE and higher are highlighted; other lines are displayed normally.
That's from systemd 229. As seen in the man page, There are no other built-in color controls for journalctl.
- 4,247
Seeking long for the answer, I actually figured out what works for me (with Rails logs and journalctl) – just add --all option.
journalctl -u puma --all
From manpage:
-a, --all Show all fields in full, even if they include unprintable characters or are very long. By default, fields with unprintable characters are abbreviated as "blob data". (Note that the pager may escape unprintable characters again.)
- 199
I use ccze for all the logs.
Example for jornalctl with color.
journalctl -b -k -f | ccze
journalctl -b -k -f | ccze -A
Other examples.
tail -f /etc/nginx/logs/access.log | ccze
tail -f /etc/unbound/unbound.log | ccze
Exporting logs
to export the log to HTML and save it to /root/syslog.html:
ccze -h -o nolookups /root/syslog.html
I hope you find it useful.
- 103
- 4
- 75
It gives color to log files and command outputs:
ccze -A </etc/nsswitch.conf | catshowsnsswitch.confwith colors, another way could becat /etc/nsswitch.conf | ccze -Atail -f /var/log/syslog | ccze ditto executetail -f /var/log/syslogbut here it shows with colors, another form could beccze -A </var/log/syslog | less -Rccze -A </home/pepe.txt | less -R idem. To run less /home/pepe.txtbut displays it with colors.ccze -h -o nolookups </var/log/syslog> /root/syslog.htmlexports the log to HTML and saves it to/root/syslog.html.
- 75
