Dear CentOS folk,
I've been try to solve one issue with rsyslog on CentOS 6, but can't figure it out. I've searched through rsyslog documentation, and used Google but not found anything that matches my issue.
I'm sending output of a program to rsyslog using "logger -t progname". I've got the following config snippet in /etc/rsyslog.d:
$FileCreateMode 0644 if $programname == 'progname' then /var/log/prog.log & ~
This works. However, the program sometimes produces blank lines its output, and they get logged by rsyslog as well. I want to make rsyslog ignore empty lines. I am trying the following, but it doesn't work:
if $programname == 'progname' and $msg != '\n' then /var/log/prog.log
Does anyone know how to get this to work in rsyslog? This is rsyslog 5 on CentOS 6.
Regards, Anand
On 29/02/16 15:59, Anand Buddhdev wrote:
This works. However, the program sometimes produces blank lines its output, and they get logged by rsyslog as well. I want to make rsyslog ignore empty lines. I am trying the following, but it doesn't work:
if $programname == 'progname' and $msg != '\n' then /var/log/prog.log
Does anyone know how to get this to work in rsyslog? This is rsyslog 5 on CentOS 6.
Well, no-one replied to it, but I eventually figured it out myself. Rsyslog converts an empty line (containing just a newline) into a message of one space, so the correct incantation is:
if $programname == 'progname' and $msg != ' ' then /var/log/prog.log
Anand