【问题标题】:How to forward logs using rsyslog client如何使用 rsyslog 客户端转发日志
【发布时间】:2021-01-11 20:54:36
【问题描述】:

我需要将消息从日志文件转发到另一个 IP - 比如说127.0.0.1 514。我如何做到这一点?

我使用了 rsyslog 文档中的this example

module(load="imfile" PollingInterval="10") #needs to be done just once



# File 2
input(type="imfile"
     File="/path/to/file2"
     Tag="tag2")

以及为其提供以下规则:

*.*      @127.0.0.1:514

但这最终发送了包括日志在内的所有系统日志。

那么如何正确使用规则集、输入块和*.* @127.0.0.1:514 将日志从文件/path/to/file2 发送到127.0.0.1:514

谢谢

【问题讨论】:

    标签: syslog rsyslog


    【解决方案1】:

    在指定输入时,还要说明要应用哪个规则集。规则集外的输入不会被规则集处理。

    module(load="imfile")
    input(type="imfile" File="/path/to/file2" Tag="tag2" ruleset="remote")
    ruleset(name="remote"){
     action(type="omfwd" target="127.0.0.1" port="514" protocol="udp")
     # or use legacy syntax:
     # *.*  @127.0.0.1:514
    }
    

    【讨论】:

      猜你喜欢
      • 2019-08-02
      • 2017-11-07
      • 2020-05-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-15
      • 1970-01-01
      相关资源
      最近更新 更多