template(name="remote" type="string" string="%msg%")

string

[root@node01 log]# cat /etc/rsyslog.conf
module(load="imfile")
template(name="remote" type="string" string="%msg%")
input (
 type="imfile"
 File="/root/log/a2.log"
 Tag="testlog02"
 PersistStateInterval="10"
 reopenOnTruncate="on"
 Severity="info"
 Facility="local5"
 ruleset="chat"
)

ruleset (name="chat"){
   action(type="omfwd" Target="192.168.137.3" Port="514" Protocol="tcp" template="remote")
}


template(name="remote" type="string" string="%msg%");


这个非常类似于 legacy template statement. 它有一个强制性的参数字符串,

持有要应用的模板字符串。

一个 template string  是固定文本和替换变量的混合。

那些变量是从消息或者其他动态内存中提取 当最终的字符串是被传递到一个插件。

This is a sample for a string-based template: 有一个例子用于基于字符串的模板:

template(name="tpl3" type="string"
         string="%TIMESTAMP:::date-rfc3339% %HOSTNAME% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%
"
        )


文本在$之间是rsyslog 属性替换。简而言之,它包含使用的属性和选项用于格式化和进一步处理。

这个非常列斯于属性对象在list模板里

除了%符号外都是常量文本,在上面的例子中,我们有很多空格在属性值之间