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(ブート ログ) も試しましたが、これもうまくいきませんでした。次の 2 つの例は、試したがうまくいかなかった構文です。

例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
}

関連情報