Different services and apps have different ideas of what is worth logging, and you may not agree with what they consider worthy of logging. Some apps and services are especially chatty in logs and you may want to silence them completely.
Here are three methods for either adjusting or silencing overly chatty desktop apps and systemd services.
The systemd journal has only limited storage filtering capabilities, and defaults to store everything in case it might be useful. However, sometimes you just want to silence a desktop app or a service unit entirely or at least adjust their logging verbosity.
Adjust logging level of systemd service
You can set a minimum logging level based on the standard syslog levels of individual systemd service units.
This method works in systemd version 236 and later, but only works for programs that send logs directly to journald or syslog, or output to stdout
in syslog format.
- Create a service unit override by editing the systemd service you want to modify by running the following command:
This opens a text editor where you need to add a LogLevelMax
value. Below is an example override that restricts logging to level 3 (errors) and higher.
For reference, the standard log levels are emergency (0), alert (1), critical (2), error (3), warning (4), notice (5), info (6), and debug (6). Setting a lower number excludes the higher and less important log messages from your journal.
- Install the service override and restart the service by executing the following commands:
The service will no longer log messages with a logging level higher than the maximum level you configured.
Silencing a service’s standard output
By default, systemd will forward every standard output (stdout) and error (stderr) message to the journal. Some programs aren’t designed for this behavior and can be too chatty, especially on standard output.
You can override this behavior and discard the program’s output instead. Here’s how to modify a systemd unit file to discard program output.
- Create a service unit override by editing the systemd service you want to modify by running the following command:
This opens a text editor where you can direct the output forwarding to null instead of the journal.
- Install the service override and restart the service by executing the following commands:
The service will no longer forward standard output messages toi the journal.
Silencing a desktop app
Depending on your desktop environment, your programs’ standard output (stdout
) and error (stderr
) messages may be forwarded to the journal. You can override this behavior by overriding the application definition file (the .desktop
file) for programs you want to silence.
- Start by copying the existing desktop file to your user’s applications folder (you may need to create this directory.) This file must have the same name as the system-wide installation to avoid ending up with duplicate application entries.
- Then, edit your user’s copy of the file (
~/.local/share/applications/example.desktop
) and modify theExec
statement to silence standard output.
The first example shows how to modify the Exec
statement to silence just the standard output, and the second example shows how to silence standard output and error. (Changes from the original Exec
statement are highlighted in blue.)
Depending on the program, it may be necessary to silence standard error messages though be careful so you don’t end up silencing important error messages entirely.
You can, of course, setup more specific filtering of messages here using grep
and other utilities, but this is out of scope for this tutorial.
- Install the modified application definition file and update the application definition database. You’ll only need to execute one of these commands, but which one varies by the desktop environment. You can just run both without any problems.
- Lastly, you’ll need to restart the app for the changes to take effect.