Validation

validation

Customization: Case-insensitive highlighting of «err» and «error» in the terminal

There are several ways to do this:

1. Editing the journalctl configuration file:

The file /etc/systemd/journald.conf by default only contains the line Storage=persistent.

  • Open the journalctl configuration file:
sudo nano /etc/systemd/journald.conf
  • Add the following lines to the [Highlight] section:
# Journald configuration file

Storage=persistent
[Highlight]
Err=red
Error=red
# Case-insensitive highlighting
IgnoreCase=yes
  • After adding these lines, the words «err» and «error» will be highlighted in red in the journalctl output.
  • Save the file and restart the journald service:
sudo systemctl restart systemd-journald
  • Now, when you enter the command:
sudo journalctl -u zetacored -f -n 100
  • You should see that the words «err» and «error» are highlighted in red.

The IgnoreCase=yes setting in the /etc/systemd/journald.conf file does not affect the case sensitivity of commands entered using systemctl.

IgnoreCase=yes only affects the display of the words «err» and «error» in the output of the journalctl command.

2. Using the -i option:

  • Use the -i option to ignore the case:
sudo journalctl -u myService.service -f -n 100 -i "err\|error"

Choose the method that works best for you.

Important:

  • Changes to the journalctl configuration file will be applied to all users of the system.
  • The -i option can be used to ignore the case when filtering.

Additional tips:

  • You can change the ANSI code to use a different color for highlighting.
  • You can add other words or phrases that will be highlighted.


Description of journald.conf functions

less /etc/systemd/journald.conf
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See journald.conf(5) for details.

[Journal]
#Storage=auto
#Compress=yes
#Seal=yes
#SplitMode=uid
#SyncIntervalSec=5m
#RateLimitIntervalSec=30s
#RateLimitBurst=10000
#SystemMaxUse=
#SystemKeepFree=
#SystemMaxFileSize=
#SystemMaxFiles=100
#RuntimeMaxUse=
#RuntimeKeepFree=
#RuntimeMaxFileSize=
#RuntimeMaxFiles=100
#MaxRetentionSec=
#MaxFileSec=1month
#ForwardToSyslog=yes
#ForwardToKMsg=no
#ForwardToConsole=no
#ForwardToWall=yes
#TTYPath=/dev/console
#MaxLevelStore=debug
#MaxLevelSyslog=debug
#MaxLevelKMsg=notice
#MaxLevelConsole=info
#MaxLevelWall=emerg
#LineMax=48K
#ReadKMsg=yes

  1. [Journal]:
    • This is the header of the configuration section, indicating that the parameters for configuring systemd-journald will follow.
  2. #Storage=auto:
    • This parameter defines how the journal will be stored. In this case, the hash (#) at the beginning of the line makes it a comment, rendering it inactive. auto means automatic selection of storage method.
  3. #Compress=yes:
    • This parameter determines whether the journal will be compressed. yes indicates that compression is enabled.
  4. #Seal=yes:
    • This parameter determines whether the journal will be sealed, meaning it will not be subject to modifications.
  5. #SplitMode=uid:
    • Specifies how the journals are split among users. In this case, commented out, indicating the use of the default value (uid).
  6. #SyncIntervalSec=5m:
    • Defines the interval for syncing journal records to disk. Here, it is set to 5 minutes.
  7. #RateLimitIntervalSec=30s:
    • Defines the time interval for rate-limiting journal entries. In this case, commented out, indicating the use of the default value (30 seconds).
  8. #RateLimitBurst=10000:
    • Defines the maximum number of entries that can be added before rate-limiting takes effect.
  9. #SystemMaxUse=:
    • Defines the maximum disk space that can be occupied by system journals.
  10. #SystemKeepFree=:
    • Defines the minimum free disk space for system journals.
  11. #SystemMaxFileSize=:
    • Defines the maximum file size for system journals.
  12. #SystemMaxFiles=100:
    • Defines the maximum number of files for system journals.
  13. #RuntimeMaxUse= and subsequent lines are similar to system settings but apply to user session journals.
  14. #MaxRetentionSec=:
    • Defines the maximum retention time for journal entries.
  15. #MaxFileSec=1month:
    • Defines the maximum time each journal file will be retained.
  1. #ForwardToSyslog=yes:
    • Specifies whether systemd-journald should forward logs to the system syslog. In this case, it’s commented out, indicating the default behavior is used (yes).
  2. #ForwardToKMsg=no:
    • Determines whether systemd-journald should forward logs to the kernel message ring buffer (KMsg). Here, it’s disabled.
  3. #ForwardToConsole=no:
    • Defines whether systemd-journald should forward logs to the console. In this case, it’s disabled.
  4. #ForwardToWall=yes:
    • Decides whether systemd-journald should forward logs to the «wall,» which may mean output to all terminals. Here, it’s commented out, indicating the default behavior (yes).
  5. #TTYPath=/dev/console:
    • Specifies the path to the terminal (TTY) to which logs will be sent. Here, it’s set to the system console.
  6. #MaxLevelStore=debug:
    • Sets the maximum logging level that will be stored in the systemd-journald journal. Here, the level is set to debug.
  7. #MaxLevelSyslog=debug:
    • Sets the maximum logging level that will be forwarded to the system syslog. Here, the level is set to debug.
  8. #MaxLevelKMsg=notice:
    • Sets the maximum logging level that will be forwarded to the kernel message ring buffer (KMsg). Here, the level is set to notice.
  9. #MaxLevelConsole=info:
    • Sets the maximum logging level that will be forwarded to the console. Here, the level is set to info.
  10. #MaxLevelWall=emerg:
    • Sets the maximum logging level that will be forwarded to the «wall.» Here, the level is set to emerg.
  11. #LineMax=48K:
    • Specifies the maximum size of a single line in the systemd-journald journal. Here, it’s set to a size of 48 kilobytes.
  12. #ReadKMsg=yes:
    • Determines whether systemd-journald should read messages from the kernel message ring buffer (KMsg). Here, it’s set to yes.