In syslog (Raspbian rsyslog swVersion="8.1901.0"),
I am trying to match / filter a system msg containing a specific string BOTH to /var/log/syslog
(default) AND to a custom separate log file, i.e.: /var/log/nut.log
.
I have been able to achieve the by placing the following filter lines in /etc/rsyslog.conf
:
# NUT logging: Include USB msgs since montoring UPS via only USB
:msg,contains,"USB" /var/log/nut.log
& stop
:msg,contains,"nut-" /var/log/nut.log
& stop
The & stop
is needed to halt the filters once a match is made. I believe the preferred method is to place this in a dedicated file, i.e.: /etc/rsyslog.d/0-nut.conf
But, when I do that, the filters stop logging to /var/log/syslog
, and exclusively log to /var/log/nut.log
... ?
Is there a different way to do this?
Thx!