我是 rsyslog 新手。我有多个服务器(rsyslog 服务器)将系统日志消息发送到远程服务器(syslog-ng 服务器)。 现在,我正在将所有内容发送到远程服务器。我想过滤掉特定文件中的日志并将其发送到远程服务器。
10-custom.conf - 这是我正在使用的自定义配置文件
#Forward specific logs to remote server
module(load="imfile")
input(type="imfile"
file="/var/log/tomcat8/bar.log"
Tag="bar:")
input(type="imfile"
file="/var/log/tomcat8/foo.log"
Tag="foo:")
input(type="imfile"
file="/var/log/dpkg.log"
Tag="dpkg:")
input(type="imfile"
file="/var/log/syslog"
Tag="syslog:")
input(type="imfile"
file="/var/log/auth.log"
Tag="auth:")
input(type="imfile"
file="/var/log/kern.log"
Tag="kern:")
#if $Tag == "catalina:" then @@remoteserver:port
:syslogtag, isequal, "catalina:" @@remoteserver:port
& stop
我正在尝试根据标签过滤并将其发送到远程服务器。我无法让这个工作。
进行此设置的最佳方法是什么?
提前致谢!
最佳答案
您可以将语句放在 rsyslog.conf 之上,如下所述:
https://www.rsyslog.com/discarding-unwanted-messages/
例如,假设您只想将特定的设施消息发送到远程日志服务器,例如所有相关的邮件消息,无论优先级如何,请将以下行添加到 rsyslog 配置文件中:
mail.* @192.168.10.254:514
关于linux - 如何使用 rsyslog 仅发送特定文件到远程服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53533743/