[CentOS] Discarding empty lines in rsyslog

Mon Feb 29 14:59:13 UTC 2016
Anand Buddhdev <anandb at ripe.net>

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