【问题标题】:How to use more than one template with rsyslog如何在 rsyslog 中使用多个模板
【发布时间】:2015-05-12 06:46:02
【问题描述】:

我正在使用 rsyslogd,我想根据消息的内容(使用模板)将消息放入自定义日志文件中,并使用自定义文件格式(使用模板)。 rsyslog documentation 提供了有关如何创建模板并根据内容/设施/等应用它的良好信息。的消息,但没有展示如何将多个模板应用到单个消息。

【问题讨论】:

    标签: rsyslog


    【解决方案1】:

    经过大量搜索,我在 this 堆栈溢出答案上找到了一个在单个消息上使用多个模板的示例,但由于该问题涉及不同的主题,我认为这是值得自己提出的问题。

    解决方案就像下面的示例一样简单(复制自上面链接的答案):

    $template MsgFormat,"%msg%\n"
    $template ApacheRemoteCustom,"/var/log/manager/access.log"
    if $syslogfacility-text == 'local6' and $programname == 'apache' then -?ApacheRemoteCustom;MsgFormat
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-18
      • 1970-01-01
      • 1970-01-01
      • 2013-10-23
      • 2012-09-06
      • 2019-03-23
      • 2017-07-30
      • 1970-01-01
      相关资源
      最近更新 更多