Syslog
Last edited
Note
syslogis a protocol and concept for how to structure log messages and transport them.rsyslog(rocket-fast syslog) is a specific implementation and is default syslog daemon on most Linux distros.
Before syslog was defined every program was free to make up its own logging policy.
Think about log messages as a stream of events and rsyslog as an event-stream processing engine. Log message “events” are submitted as inputs, processed by filters and forwarded to output destinations (files, terminals, other machines).
- The
rsyslogdprocess typically starts at boot and runs continuously. - Programs that are syslog aware write log entries to the special file
/dev/log, a UNIX domain socket.
rsyslog configuration test
My example system
ubuntu 24has supplant thersyslogdsocket with a symlink to systemd’s journald, to centralize logging, ingestion and storage.$ ls -l /dev/log lrwxrwxrwx 1 root root 28 May 26 08:23 /dev/log -> /run/systemd/journal/dev-log $ ls -l /run/systemd/journal/dev-log srw-rw-rw- 1 root root 0 May 26 08:23 /run/systemd/journal/dev-logChecking the systemd status of the service it is running -
rsyslogdcontinues to run as a daemon for additional filtering and processing.Let’s check what
rsyslogdis doing, no freeloaders!#/etc/rsyslog.conf # global configs are here..... # .....[snip]..... # Include all config files in /etc/rsyslog.d/ # $IncludeConfig /etc/rsyslog.d/*.confAs expected
rsyslogis pointing to a folder of configs/etc/rsyslog.d/*.conf#/etc/rsyslog.d/50-default.conf # Looking at this first rule, filting the facility (source) field that matches auth # or authpriv* and it's forwarding to the file /var/log/auth.log auth,authpriv.* /var/log/auth.logSo it is doing something!
Let’s try making a change
sudo vim /etc/rsyslog.d/50-default.conf # Let's forward the logs syslog filters to a different path auth,authpriv.* /var/log/spongebob.log # Reload rsyslog's config sudo systemctl restart rsyslog # And boom! $ cat /var/log/spongebob.log 2026-06-04T21:15:59.529208-04:00 k3s sudo: pam_unix(sudo:session): session closed for user root 2026-06-04T21:16:03.960824-04:00 k3s sshd[1118358]: Received disconnect from 192.168.2.11 port 60762:11: disconnected by user 2026-06-04T21:16:03.960992-04:00 k3s sshd[1118358]: Disconnected from user mat 192.168.2.11 port 60762
rsyslog configurations
Formats
Rsyslog has 3 syntaxes
# sysklogd format (original/simplest), implicit:
auth,authpriv.* /var/log/auth.log
# RainerScript (modern), explicit
auth,authpriv.* action(type="omfile" file="/var/log/auth.log")
# Legacy rsyslog directives ($ syntax)
# Primarily for global config and module loading not filter/action rulesModules
- modules are written C, they parse and can mutate messages
- modules follow the naming convention:
im*input modulesom*output modulesmm*message modifiers
Examples of modules are:
imjournalsystemd journalimfileconverts a plain text file to syslog formatimtcp&imudpaccept messages over tcp and udp, usefulimmarkmodule produces timestamp messages at regular intervals, this can help you figure out that your machine crashed between random hours not just “some time last night”omfilewrite messages to a file, most commonly usedomfwdforwards message to a remote syslog server (tcp/udp) used for centralized loggingommysqlsend messages to a MySQL database
Config Examples
Simple
This reads from a log file and stores to another log file, contrived by a good sanity test before sending elsewhere.
# /etc/rsyslog.d/55-kubeview.conf
module(load="imfile" mode="inotify")
input(
type="imfile"
Tag="kubeview"
File="/var/log/kubeview.log"
Severity="info"
)
if $programname startswith "kubeview" then {
action(type="omfile" file="/var/log/kubeview-out.log")
}TODO: send to a central server
https://docs.rsyslog.com/doc/configuration/modules/idx_output.html
Rsyslog TLS
Rsyslog can send and receive log messages over TLS on port 6514.