[CentOS] Discarding empty lines in rsyslog

Mon Feb 29 23:52:32 UTC 2016
Anand Buddhdev <anandb at ripe.net>

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