Home:ALL Converter>Prevent forwarding of systemd service logs to syslog without affecting other service logs sent to syslog

Prevent forwarding of systemd service logs to syslog without affecting other service logs sent to syslog

Ask Time:2017-07-21T17:36:51         Author:achilles

Json Formatter

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.

Author:achilles,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/45234241/prevent-forwarding-of-systemd-service-logs-to-syslog-without-affecting-other-ser
BarbosSergos :

The second option with StandardOutput=null should work. I think what you need is to redirect also STDERR to /dev/null, by adding StandardError=null.\nSummarize - in your *.service file should be two lines:\n\n[Service]\nStandardOutput=null\nStandardError=null\n\n\nRefer SYSTEMD.EXEC(5) man page for more details. ",
2019-04-11T08:04:22
yy