【问题标题】:Rsyslog using else in configRsyslog 在配置中使用 else
【发布时间】:2020-10-14 01:03:29
【问题描述】:

您好,我需要配置文件:

if $FROMHOST-IP == '192.168.xx.xxx' then { action(type="omfile" file="/var/log/rsyslog/myHostName/device.log") }
else {*.* ?RemoteHost}

但是重启后 rsyslog 给我这个消息:

Oct 13 12:12:40 syslog-new rsyslogd[29378]: error during parsing file /etc/rsyslog.conf, on or before line 118: syntax error on token 'else' [v8.1901.0 try https://www.rsyslog.com/e/2207 ]
Oct 13 12:12:40 syslog-new rsyslogd[29378]: could not interpret master config file '/etc/rsyslog.conf'. [v8.1901.0 try https://www.rsyslog.com/e/2207 ]

请帮忙。 谢谢

【问题讨论】:

    标签: logging rsyslog


    【解决方案1】:

    关于 if..then..else 的 RainerScript 文档有些缺乏细节,但为了将 if 的这种用法与同样以 if 开头的旧过滤器语法区分开来,您似乎需要附上() 中的表达式。试试

    if ($FROMHOST-IP == '192.168.xx.xxx') then { action(type="omfile" file="/var/log/rsyslog/myHostName/device.log") }
    else {*.* ?RemoteHost}
    

    【讨论】:

      猜你喜欢
      • 2016-08-10
      • 2017-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多