我正在使用 rsyslogd,我想根据消息的内容(使用模板)将消息放入自定义日志文件中,并使用自定义文件格式(使用模板)。该rsyslog现在文档提供了有关如何创建一个模板,并基于内容/设备/等应用它良好的信息。的消息,但没有显示如何将多个模板应用于单个消息。
经过多次搜索,我在此堆栈溢出答案中找到了一个示例,该示例在一条消息上使用多个模板,但由于该问题涉及不同的主题,因此我认为这值得提出自己的问题。
解决方案就像下面的例子一样简单(从上面链接的答案中复制):
$template MsgFormat,"%msg%\n"
$template ApacheRemoteCustom,"/var/log/manager/access.log"
if $syslogfacility-text == 'local6' and $programname == 'apache' then -?ApacheRemoteCustom;MsgFormat
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5061 次 |
| 最近记录: |