My computer runs serveral java processes as systemd services.The systemd logs get accumulated in the syslog eventually leading to low disk space . How to re-direct the logs started by systemd services towards /dev/null so that it does not accumulate in syslog.The machine is constantly running out of disk space due to this issue.However , I need to be able to use journalctl to view the systemd service logs. The possible solutions I found were :
1.To modify configurations in /etc/systemd/journald.conf by setting 'ForwardToSyslog=no'
2.Adding StandardOutput=null within the systemd service file itself
However the first solution completely stopped all the logs sent to syslog and solution 2 did not work.I wish to stop forwarding only the log messages from systemd services.
To enable ForwardToSyslog, open /etc/systemd/journald. conf and set the ForwardtoSyslog option to “yes”. In addition, set the MaxLevelSyslog parameter to “debug” to allow logs of any level to be forwarded to syslog.
The first big difference with other syslog management tools is that the journal stores log data in a binary format rather than plain text files, so it cannot be read directly by humans or used by the traditional and well-known toolset. journal data logs are usually processed by an application called journalctl.
With in-memory journaling, systemd creates its journal files under the /run/log/journal directory. The directory is created if it doesn't exist. With persistent storage, the journal is created under /var/log/journal directory; again, the directory is created by systemd if needed.
systemd-journald is a system service that collects and stores logging data. It creates and maintains structured, indexed journals based on logging information that is received from a variety of sources: Kernel log messages, via kmsg. Simple system log messages, via the libc syslog(3) call.
Similarly on a Redhat 7.4 box, running systemd-219-42.el7_4.1.x86_64, I was unable to turn off log redirection with the 'ForwardToSyslog=no' setting in /etc/systemd/journald.conf.
I instead had success with setting 'MaxLevelSyslog=warning' which removed all the INFO and DEBUG level messages that were being forwarded to rsyslog.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With