LoginSignup
2
2

More than 5 years have passed since last update.

rsyslogでログ出力先を分けたいときのメモ

Posted at

やりたいこと

  1. 送信元ネットワークでログ出力先を分けたい
  2. その上で、特定ホストの特定のメッセージを含む場合に破棄したい

config

2→1の順で定義する。

/etc/rsyslog.confに以下を追記

#192.168.1.1から受信した'hoge'を含むメッセージは破棄
if $fromhost-ip == '192.168.1.1' and ($msg contains 'hoge') then ~
#192.168.1.0/24から受信したsyslogをsyslog-hogehoge.logに出力
if $fromhost-ip startswith '192.168.1.' then /var/log/syslog-hogehoge.log 
#上記ファイルを出力後、/var/log/messagesには出力されないようメッセージを廃棄
& ~
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2