How to Enable Colorized Output in journalctl: A Complete Guide for Linux System Debugging


1 views

When troubleshooting Linux systems, journalctl is our go-to tool for examining system logs. While functional, the default monochromatic output makes it challenging to quickly identify critical events among thousands of log entries. Unlike dmesg --color which shows colored output by default, journalctl requires explicit configuration for proper colorization.

The simplest way to enable colors is using the --color flag:

journalctl --color=always

This persists for your current session. For permanent configuration, edit your .bashrc or create an alias:

alias journalctl='journalctl --color=always'

Systemd allows detailed color configuration through systemd-journald settings. Create or modify /etc/systemd/journald.conf:

[Journal]
Color=yes
Highlight=yes
LineMax=1024

Then reload the configuration:

systemctl restart systemd-journald

For better visual hierarchy, use priority filtering with colors:

journalctl -p err --color=always

Common priority levels:

  • emerg (0): Bright red
  • alert (1): Red
  • crit (2): Bright yellow
  • err (3): Yellow
  • warning (4): Magenta

For system-wide color settings, create a drop-in configuration:

mkdir -p /etc/systemd/journald.conf.d
echo -e '[Journal]\nColor=yes\nHighlight=yes' > /etc/systemd/journald.conf.d/colors.conf
systemctl restart systemd-journald

Advanced users can modify color schemes through terminal environment variables:

export SYSTEMD_COLORS=16
export SYSTEMD_COLORS_DIRECTORY=/usr/share/systemd/color-schemes/
journalctl --update-environment

Available color schemes include dark, light, and solarized.

If colors don't appear:

  • Verify terminal supports 256 colors with echo $TERM
  • Check systemd --version (v230+ recommended)
  • Test with SYSTEMD_COLORS=debug journalctl for diagnostics

For pipelines that strip colors, use ANSI escape code preservation:

journalctl --color=always | less -R

Or when grepping colored output:

journalctl --color=always | grep --color=always "error"

When working with journalctl, many developers notice that the default output lacks visual differentiation. While some critical messages might be highlighted, the majority of log entries appear in monochrome, making it difficult to quickly scan through logs.

Unlike dmesg which has an explicit --color flag, journalctl's color behavior is controlled differently. The good news is that journalctl does support color output through the following methods:

# Basic color output
journalctl --output=short-precise --color=always

# For persistent configuration
sudo mkdir -p /etc/systemd/journald.conf.d
echo -e "[Journal]\nColor=yes" | sudo tee /etc/systemd/journald.conf.d/color.conf
sudo systemctl restart systemd-journald

For more granular control over colors, you can use these approaches:

# Force color even when piping to less
journalctl --color=always | less -R

# Combine with grep for specific patterns
journalctl --color=always | grep --color=always "error\|fail\|warning"

# JSON output with jq for colorized parsing
journalctl -o json | jq -C . | less -R

To make color output permanent, edit or create configuration files:

# ~/.bashrc or ~/.zshrc alias
alias jc="journalctl --color=always"

# Systemd-wide configuration
sudo tee /etc/systemd/journald.conf.d/10-color.conf <<EOF
[Journal]
Color=yes
EOF

If colors still don't appear:

  • Verify your terminal supports ANSI colors with echo -e "\e[31mRED\e[0m"
  • Check $TERM environment variable is set correctly
  • Try forcing colors with journalctl --color=force

For developers who need more sophisticated log visualization:

# Use ccze for enhanced coloring
journalctl -f | ccze -A

# Pipe to multitail for multiple color schemes
journalctl -f | multitail -cS syslog -