Rsyslog : Basic Usage2026/06/19 |
|
This is Basic Usage of Rsyslog that is the Log Management Service Daemon. |
|
| [1] | Depending on your OS installation configuration, if Rsyslog is not installed, you will need to perform a clean installation. |
|
root@dlp:~# apt -y install rsyslog
|
| [2] | Stored rules of logging data are configured in [/etc/rsyslog.conf] and included files. |
|
root@dlp:~# grep -v -E "^#|^$" /etc/rsyslog.conf module(load="imuxsock") # provides support for local system logging module(load="imklog" permitnonkernelfacility="on") $RepeatedMsgReduction on $FileOwner syslog $FileGroup adm $FileCreateMode 0640 $DirCreateMode 0755 $Umask 0022 $PrivDropToUser syslog $PrivDropToGroup syslog $WorkDirectory /var/spool/rsyslog $IncludeConfig /etc/rsyslog.d/*.conf # * how to write rules : (Facility).(Priority) (Action) # # ex : *.info;mail.none;authpriv.none;cron.none /var/log/messages # ⇒ [syslog] messages of [info] Priority of all Facilities are stored in [/var/log/messages] # ⇒ but messages of [mail], [authpriv], [cron] Facilities are not stored in [/var/log/messages] # # * the [-] that is added at the head of a filename means asynchronous output # if [-] is not added, logging data are written with synchronous output # * Facilities # kern : kernel messages # auth : authentication related messages # authpriv : authentication related messages (private) # cron : cron or at related messages # mail : mail services related messages # news : news related messages # uucp : uucp related messages # daemon : daemon services related messages # user : user level processes related messages # lpr : printer related messages # syslog : internal syslog related messages # local0 - local7 : possible to use for custom settings # * Priorities # emerg : maybe panic level troubles # alert : need to correct immediately more than critical # crit : need to correct immediately # err : common errors, non urgent failures # warning : warning messages # notice : not errors but some unusual events detected # info : normal operational messages # debug : debug information # none : none (not output) # * if you'd like to store only specified priority messages # add [=] like follows # ex : kern.=crit /dev/console |
| [2] | To transfer logging data to remote Hosts, Configure like follows. |
|
###### on Syslog Server Host (receives logging data from other Hosts) ###### root@dlp:~# vi /etc/rsyslog.conf # line 21-22 : uncomment
line 23 : set allowed hosts to connect
module(load="imtcp")
input(type="imtcp" port="514")
$AllowedSender TCP, 127.0.0.1, 10.0.0.0/24, *.srv.world
if UFW is enabled, allow service port root@dlp:~# ufw allow 514/tcp
root@dlp:~#
systemctl restart rsyslog
###### on Sender Host (sends logging data to Syslog Server Host) ###### root@node01:~# vi /etc/rsyslog.conf # add to last line
action(type="omfwd"
queue.filename="fwdRule_dlp.srv.world"
queue.maxdiskspace="1g"
queue.saveonshutdown="on"
queue.type="LinkedList"
action.resumeRetryCount="-1"
Target="dlp.srv.world" Port="514" Protocol="tcp")
# queue.filename : queue filename # queue.maxdiskspace : maxdiskspace for queue # queue.saveonshutdown=on : save queue data on disk when system shutdown # queue.type=LinkedList : asynchronous queue which can store 10,000 messages # action.resumeRetryCount=-1 : continue to retry sending when syslog server does not respond # Target=*** : specify syslog server Host
root@node01:~# systemctl restart rsyslog
###### that's OK, verify settings to see logs on syslog server Host ###### root@dlp:~# tail /var/log/syslog 2026-06-19T00:15:38+00:00 node01 kernel: audit: type=1400 audit(1781828138.049:188): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="rsyslogd" pid=1625 comm="apparmor_parser" 2026-06-19T00:15:40+00:00 node01 systemd[1]: Stopping ssh.service - OpenBSD Secure Shell server... 2026-06-19T00:15:40+00:00 node01 systemd[1]: ssh.service: Deactivated successfully. 2026-06-19T00:15:40+00:00 node01 systemd[1]: Stopped ssh.service - OpenBSD Secure Shell server. 2026-06-19T00:15:40+00:00 node01 systemd[1]: sshd-keygen.service - Generate sshd host keys on first boot skipped, unmet condition check ConditionFirstBoot=yes 2026-06-19T00:15:40+00:00 node01 systemd[1]: Starting ssh.service - OpenBSD Secure Shell server... 2026-06-19T00:15:40+00:00 node01 systemd[1]: Started ssh.service - OpenBSD Secure Shell server. 2026-06-19T00:16:16.132823+00:00 dlp systemd[1]: sshd-keygen.service - Generate sshd host keys on first boot skipped, unmet condition check ConditionFirstBoot=yes 2026-06-19T00:16:16.137867+00:00 dlp systemd[1]: Starting ssh.service - OpenBSD Secure Shell server... 2026-06-19T00:16:16.168550+00:00 dlp systemd[1]: Started ssh.service - OpenBSD Secure Shell server. |
|
|