rsyslog - 如何根据 Rsyslog 中的日志严重性过滤日志?
问题描述
我是 rsyslog 的新手,我能够从客户端获取日志到服务器。但我需要根据日志严重性(意味着 INFO、ERROR、WARN)来划分它,就像这样
解决方案
试试这个在服务器端添加你的 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")
}
}
推荐阅读
- python - 使用列表分发列表以删除 python 中的列表列表
- python - 如何将嵌入矩阵转换为torch.Tensor
- c# - 如何相对添加tessdata?或使用参考中的文件夹?
- python - 遍历数据框列并确定哪些是数字的
- java - 如果调用 Subscription.request 时 Publisher 无法生成数据怎么办?
- javascript - 将多个字符串插入一个字符串而不调整索引更改
- c++ - 模板函数调用
- javascript - GraphQL 错误:预期未定义为 GraphQL 类型
- python - faulthandler.enable() 在用于生产的库中?
- databricks - Databricks Delta Lake `mergeSchema` 选项如何处理不同的数据类型?