
我正在尋找一種方法來編寫具有多個匹配值的單個規則,如果訊息包含第一個單字或第二個單詞,則不要將這些行寫入日誌檔案。
這可行但不乾燥:
if $msg contains "WARNING:" then { Action (type="omfile" File="/var/log/ignorethis") stop }
if $msg contains "IGNORE THIS MESSAGE:" then { Action (type="omfile" File="/var/log/ignorethis") stop }
這個不起作用:
if $msg contains "WARNING: || IGNORE THIS MESSAGE:" then { Action (type="omfile" File="/var/log/ignorethis") stop }
答案1
這有效嗎?
if ($msg contains "WARNING:") or ($msg contains "IGNORE THIS MESSAGE:") then { Action (type="omfile" File="/var/log/ignorethis") stop }
這rsyslog 表達式文檔可能會有所幫助。