![rsyslog conf 檔案語法多個過濾器](https://rvso.com/image/762152/rsyslog%20conf%20%E6%AA%94%E6%A1%88%E8%AA%9E%E6%B3%95%E5%A4%9A%E5%80%8B%E9%81%8E%E6%BF%BE%E5%99%A8.png)
我正在 Red Hat 8 系統上設定 rsyslog。我已經完成了第一部分,它根據來源 IP 進行過濾,並將日誌寫入特定文件中,如下所示:
if $fromhost-ip startswith '10.1.2.45' then /var/log/test_all.log
& ~
我想做的,但我無法找出正確的語法,是檢查主機IP和授權權限設施並將其寫入文件。
我知道,我需要在上面列出的聲明之前添加該聲明,但我無法讓它發揮作用。我也嘗試過local7
(啟動日誌),但也不起作用。接下來的兩個範例是我嘗試過但不起作用的語法:
範例1:
if $fromhost-ip startswith '10.1.2.45' and $syslogfacility-text == 'local7' then /var/log/test_boot.log
& stop
if $fromhost-ip startswith '10.1.2.45' and $syslogfacility-text == 'local10' then /var/log/test_secure.log
& stop
if $fromhost-ip startswith '10.1.2.45' then /var/log/test_all.log
& stop
範例2:
if $fromhost-ip startswith '10.1.2.45' and $syslogfacility-text == 'authpriv.*' then /var/log/test_secure.log
& stop
if $fromhost-ip startswith '10.1.2.45' then /var/log/test_all.log
& stop
答案1
在這裡找到解決方案: rsyslog 設定語法
if $fromhost-ip startswith '10.1.2.45' then {
authpriv.* -/var/log/test_secure.log
-/var/log/test_all.log
& stop
}