Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Processes started with systemd are logging to /var/log/syslog and /var/log/daemon.log

I'm running a couple of python scripts on a Beaglebone Black, both started at init by systemd. I noticed yesterday that my eMMC flash was completely full, and the reason was I had 1.8 gigs of log files. It seems that the standard output of these scripts (they generate a good amount of data for debugging purposes) is being logged to both /var/log/syslog and /var/log/daemon.log. Also, /var/log/messages has a ton of entries about "rate-limiting".

Now, I assume I could fix this by disabling standard output on these scripts. However, I would much rather preserve that capability and somehow tell systemd not to log that data. However, I've been unable to find information on this.

Here is an example of my current .service file:

[Unit]
Description=Description of my process
After=network.target
[Service]
Type=simple
ExecStart=/opt/myprocess
[Install]
WantedBy=multi-user.target

I should note that I originally had syslog.target as an "After" target, just because the example I was following had it. But I have since removed it and it doesn't seem to solve the problem.

Any help or insight into this problem would be greatly appreciated.

Edit: I may have found the answer here:

http://www.kibinlabs.com/systemd-logging-tricks/

Adding StandardOutput=null and seeing if that fixes it. Looks promising.

Edit 2: It does.

like image 239
Dave Avatar asked Jun 10 '15 13:06

Dave


People also ask

Which logging system is provided by systemd?

The systemd daemon uses a centralized logging system called a journal, which is managed by the journald daemon. This daemon collects all log entries generated by the Linux kernel or any other systemd unit service regardless of their origin and stores them in a format that is easy to access and manipulate.

What is var log syslog in Linux?

Linux logs will display with the command cd/var/log. Then, you can type ls to see the logs stored under this directory. One of the most important logs to view is the syslog, which logs everything but auth-related messages. Issue the command var/log/syslog to view everything under the syslog.

What is the difference between VAR log messages and VAR log syslog?

/var/log/messages instead aims at storing valuable, non-debug and non-critical messages. This log should be considered the "general system activity" log. /var/log/syslog in turn logs everything, except auth related messages. Other insteresting standard logs managed by syslog are /var/log/auth.

What is a logging daemon?

A daemon log is a program that runs in the background and is essential for system operations. These logs have their own category of logs and are seen as the heart of the logging operations for any system. The path for the system login daemon's configuration is /etc/syslog.


1 Answers

SystemD does not log files in /var/log by itself, ever.

If log messages are showing up in /var/log, this suggests that your system is running a "syslog" daemon, which is receiving log messages either (a) by reading the systemd journal, or (b) by applications using syslog directly.

Simply disabling your syslog daemon would prevent files from being written in /var/log. Messages will still be written to the system journal, but there are fairly flexible controls available to you to limit the space used by these files. See the journald docs for more information.

like image 134
larsks Avatar answered Nov 15 '22 00:11

larsks