Rsyslog – action AND action

rsyslogsyslog

I want to create rule to send data from facility to file AND to MySQL database.

How it can realized? Only by adding second line like:

syslog.*                         /var/log/syslog.log
syslog.*                         :ommysql:localhost,database,user,password

Or there is some more correct way?

Best Answer

Or there is some more correct way?

I don't know if it would be considered more correct, since I think it is an rsyslog specific feature (and it might be considered "more correct" to do things in a syslog compatible way whenever possible...or it might not) but there is the ampersand:

syslog.*      /var/log/syslog.log
&             :ommysql:localhost,database,user,password

It's documented here, if you search the page for "ampersand". I believe "legacy description" there refers to not to "syslog compatible" behaviour but to the legacy behavior of rsyslog, which now implements something called RainerScript for writing rules. As to whether that's really easier or more correct in this case I can't say.

Related Question