首页 > 解决方案 > 如何根据 Rsyslog 中的日志严重性过滤日志?

问题描述

我是 rsyslog 的新手,我能够从客户端获取日志到服务器。但我需要根据日志严重性(意味着 INFO、ERROR、WARN)来划分它,就像这样

标签: rsyslog

解决方案


试试这个在服务器端添加你的 rsyslog.conf 文件

module(load="imuxsock") # provides support for local system logging
#module(load="immark")  # provides --MARK-- message capability

# provides UDP syslog reception
module(load="imudp")
input(type="imudp" port="514")

# provides TCP syslog reception
module(load="imtcp")
input(type="imtcp" port="50514" ruleset="remote")


Ruleset (name="remote"){
   # action (type="omfile" file="/var/log/jvh.log")          
   if $msg contains 'ERROR' then {
        action (type="omfile" file="/var/log/jvhErr.log")
   }else if $msg contains 'INFO' then {
       action(type="omfile" file="/var/log/jvhInfo.log")
   }else {
        action(type="omfile" file ="/var/log/jvhOther.log")
   }

}


推荐阅读