journalctl: how to display colors in its output?
If the original daemon output is already colorized, but the colors are being lost when using
--output cat option will restore them. See the manual for more details.
Install ccze, then use it like this:
journalctl -b -k -f | ccze [-A] [-o nolookups]
-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.
The color support of
journalctl is documented in
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
ccze for all the logs.
Example for jornalctl with color.
journalctl -b -k -f | ccze journalctl -b -k -f | ccze -A
tail -f /etc/nginx/logs/access.log | ccze tail -f /etc/unbound/unbound.log | ccze
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.