rsyslog writes classic text logs to /var/log (syslog, auth.log,
mail.log). It works alongside journald: journald is a
structured journal, rsyslog is text files and forwarding logs over the
network to a central server.
bash
ls /var/log/ # syslog, auth.log, kern.log, ...
tail -f /var/log/syslog # the general system log
tail -f /var/log/auth.log # logins/sudo/ssh (see fail2ban)
Options
Rules live in /etc/rsyslog.conf and /etc/rsyslog.d/*.conf. Format is
facility.severity destination:
auth,authpriv.* /var/log/auth.log
mail.* -/var/log/mail.log # "-" = skip fsync on every line
*.emerg :omusrmsg:* # to every terminal
:programname, isequal, "myapp" /var/log/myapp.log # property filter by program name
# forward to a remote server:
*.* @@logserver.example.com:514 # @@ = TCP, @ = UDP
Open port 514 in the firewall. On the sender — *.* @@logserver:514.
Flood protection — $imjournalRatelimitInterval/RatelimitBurst
(otherwise a noisy service floods the log).
Troubleshooting
5
SymptomCause and fix
The log isn't being written
Is the service active (systemctl status rsyslog)? Any typo in the rule?
Check with rsyslogd -N1 (syntax) and logger -p auth.info "test" (does
it arrive).
Logs grow and fill the disk
Rotation is logrotate's job (rsyslog never cleans up on its own).
Check /etc/logrotate.d/rsyslog and see disk-usage.
Logs aren't arriving at the central server
Is the input module enabled on the receiver (imtcp/imudp, port 514)
and the port open (firewall, nc-zv host 514)? On the sender —
the @@host:514 rule.
Duplicate lines / "logged twice"
journald forwards to rsyslog (imjournal) and the same facility gets
written to several files. Clarify the rules; decide what goes where
(journalctl -u vs text files).
journald vs rsyslog — where to look
Structured search by service — journalctl (-u, _COMM=); familiar
text files and forwarding — /var/log/* (rsyslog).
See also
journalctl — Reading the systemd journal (journald) — filters by service, time, priority.
logrotate — Keeping logs from eating the disk — rotation, compression, retention; checking configs.