i needed to forward logs only if the log contained a certain keyword. I achieve this by adding this line in rsyslog.conf.

:msg, !contains, "xyz" ~

I know this condition means that if log contains anything other then "xyz" don't forward it but what it also does is totally discard the log and not even print it in local syslog. Can someone please provide me with a simple syntax which writes log for all situations but forwards it only for certain keywords. I'll be really grateful.


Ok so i figured it out myself. I needed to add this expression. Sad that it was so simple.

if $msg contains 'xyz'
then @@xxx.xx.xx.xxx:518

This always logs to local syslog but only logs to remote machine if log contains the word "xyz"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.