Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 632
achilles Avatar asked Jul 21 '17 09:07

achilles


People also ask

What configuration setting should you set in systemd-Journald to forward events to a syslog server?

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.

What is the difference between Journalctl and 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.

Where are systemd service logs stored?

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.

What is systemd-Journald?

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.


1 Answers

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.

like image 195
Shaun Dewberry Avatar answered Sep 28 '22 20:09

Shaun Dewberry