I am running what is a vanilla Ubuntu 16.04 server, and I'm trying to wrap my head around how logging is set up by default. I can see that both journald
and rsyslog
are installed and running, but it's not at all clear to me how log messages are being processed.
Most messages seem to show up both in /var/log/syslog
and via journalctl
, but I can't see any explicit configuration for forwarding between the two in either /etc/systemd/journald.conf
(which is basically all commented out by default), /etc/rsyslog.conf
or /etc/rsyslog.d/50-default.conf
.
I tried to look for official documentation, or even a blog post explaining how hese two are set up in Ubuntu, but haven't managed to find anything.
To further add to my confusion, I have executed logger -p local1.info Test
on the host, and found that nothing was written to /var/log/syslog
, while the message did show up under journalctl
.
My questions are:
- How exactly do journald and rsyslog work together on Ubuntu 16.04 (by default)?
How come messages sent fromlogger
seemingly end up in the journal, but not in syslog?
Update: Turns out logger
not working as expected was a mistake on my end, so it's not relevant to the main question.
Best Answer
By default
rsyslog
is using "imuxsock" module, the module provides:It is possible for
rsyslog
to import structured log messages from systemd-journal using a module named "imjournal" [2].It can be load like:
in:
In the other hand "systemd-journald" captures all data itself:
You can disable
rsyslogd
while you still have access to system logs usingjournalctl
.For example, centos is using "imuxsock" module to capture all "systemd-journald" data via
rsyslog
while opensuse does not have "syslog" at all.To find out why your message didn't end up to
/var/log/syslog
, you should check this file:look for
*.info
, see where they will be stored, it might be an other file likemessages
.For me it show up in both
journalctl
andsyslog
.