如何在 Red Hat 上过滤远程系统日志消息?
How to filter Remote Syslog messages on Red Hat?
我在服务器 运行 Red Hat 6 上使用统一日志,从其他服务器接收定向日志消息并使用 管理它们Rsyslog。到目前为止,/etc/rsyslog.conf 有这个规则:
if $fromhost-ip startswith '172.20.' then /var/log/mylog.log
但我不想记录包含 "kernel" 和 "dnat" 的消息,所以我想过滤所有消息,增强规则。
我该怎么做?
这个问题看起来更适合 Unix & Linux。适当地通知这不是正确的地方后,无论如何我都会通过回答来打破规则。
根据您使用的 Red Hat 版本,您可以以各种方式使用 rsyslogd 的 conditional filters or RainerScript 来表达多个逻辑规则的组合。在 Red Hat 6 上,你可以说这样的话来使用条件过滤器完成你想要的:
if ( $fromhost-ip startswith '172.20.' and \
$syslog-facility-text != 'kern' ) then /var/log/mylog.log
您可以从 Rsyslog v5 manual 中找到更多示例。
我在服务器 运行 Red Hat 6 上使用统一日志,从其他服务器接收定向日志消息并使用 管理它们Rsyslog。到目前为止,/etc/rsyslog.conf 有这个规则:
if $fromhost-ip startswith '172.20.' then /var/log/mylog.log
但我不想记录包含 "kernel" 和 "dnat" 的消息,所以我想过滤所有消息,增强规则。
我该怎么做?
这个问题看起来更适合 Unix & Linux。适当地通知这不是正确的地方后,无论如何我都会通过回答来打破规则。
根据您使用的 Red Hat 版本,您可以以各种方式使用 rsyslogd 的 conditional filters or RainerScript 来表达多个逻辑规则的组合。在 Red Hat 6 上,你可以说这样的话来使用条件过滤器完成你想要的:
if ( $fromhost-ip startswith '172.20.' and \
$syslog-facility-text != 'kern' ) then /var/log/mylog.log
您可以从 Rsyslog v5 manual 中找到更多示例。