Syslog message routing on Linux

Create new file (if needed) in /etc/rsyslog.d (file’s name should end in .conf). Make sure to add following line to it:

if $programname == 'PROGRAM_NAME' then /var/log/debug.log

if you don’t want this message to go anywhere else, add "& stop" in a separate line after it.

If messages go to custom file, don’t forget to make sure that this file is rotated as needed (by creating entry in /etc/logrotate.d) – example:

/var/log/myprogram.log # path to log file name
{
daily
rotate 14
compress
delaycompress
missingok
notifempty
create 0640 syslog adm # appropriate permissions
postrotate
systemctl reload rsyslog >/dev/null 2>&1 || true
endscript
}


Posted

in

by

Tags: