rsyslog conf 檔案語法多個過濾器

rsyslog conf 檔案語法多個過濾器

我正在 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
}

相關內容