Configuration 使用rsyslog将msg属性更改为新值

Configuration 使用rsyslog将msg属性更改为新值,configuration,replace,rsyslog,msg,Configuration,Replace,Rsyslog,Msg,我有以下rsyslog配置: $template f_x,"/path/%programname%.%$YEAR%%$MONTH%%$DAY%%$HOUR%.log" if $programname == 'xyz' and $msg contains 'Hello World' or $msg contains 'FATAL' then $msg = 'Starting xyz' ?f_x & ~ 在此配置中,如何将我的receiv

我有以下rsyslog配置:

    $template f_x,"/path/%programname%.%$YEAR%%$MONTH%%$DAY%%$HOUR%.log"

    if $programname == 'xyz' and $msg contains 'Hello World' or $msg contains 'FATAL'         
    then $msg = 'Starting xyz' ?f_x
    & ~
在此配置中,如何将我的receive$msg属性从“Hello World”更改为$msg='BlablaBlaBlaBlaBla',并将最后一个$msg值(%programname%%.%$YEAR%%.$MONTH%%.$DAY%%$$HOUR%.log)写入文件(%programname%%.$YEAR%%.$HOUR%


提前感谢

您不能覆盖
msg
属性

从rsyslog 7开始,您可以通过将CEE/lumberjack属性与自定义模板一起使用来实现这一点。以下是一个例子:

# Notice the use of $!msg in template string
template(name="logline" type="string"
         string="%TIMESTAMP:::date-rfc3339% %HOSTNAME% %syslogtag%%$!msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n")

# If the message matches your conditions, set $!msg to your custom string
if ($programname == 'xyz' and $msg contains 'Hello World' or $msg contains 'FATAL') then set $!msg = "Starting xyz";
# Otherwise, use the msg property value
else set $!msg = $msg;

# Finally, use the custom template
action(type="omfile" file="/tmp/logfile" template="logline")
有关rsyslog中CEE/lumberjack属性的更多信息,请参阅