1 year ago

#131755

test-img

user5580578

Systemd service should log to journal but not to rsyslog (/var/log/messages)

Why is the log data also displayed in the file "/var/log/messages" if you specify StandardOutput=null and StandardError=journal in the systemd service? I'm using Centos7 as the operating system.

[Service]
Restart=always
TimeoutStartSec=1200
StandardOutput=null
StandardError=journal

I can see both messages in journal and in the file /var/log/messages.

journalctl -u my_service
----
systemd[1]: my_service.service holdoff time over, scheduling restart.
----
cat /var/log/messages | grep my_service
----
systemd[1]: my_service.service holdoff time over, scheduling restart.
----

What additional adjustments do I have to make so that the service only logs its error messages in the journal?

EDIT:

I use the default configuration for journal "/etc/systemd/journald.conf". All lines are commented out.

centos7

systemd

journal

0 Answers

Your Answer

Accepted video resources