我正在尝试在 rsyslog 服务器中构建来自 D-Link DAP-2310 的日志。它具有非标准日志格式,我的想法是使用 rsyslog 模板中的正则表达式来修复该问题。当我使用 rsyslogd -N1 解析 rsyslog.conf 时,结果确实令人沮丧。
msg 数据项看起来像AA:BB:CC:DD:EE] [app-name] log message
第一部分是mac地址,其中第一部分“[00:”被放置在另一个数据项中,不要问为什么。第二部分“[app-name]”是发送消息的应用程序/实例。最后一部分“日志消息”是记录的操作。
有趣的部分是 i) 应用程序名称和 ii) 日志消息。
我已经验证了以下正则表达式http://www.rsyslog.com/regex/他们俩都很有魅力。
- \[(.+)\]
- \[.+\](.+)
完整的模板声明如下所示:
template(name=”AP_tmpl” type=”list”) {
property(name=”timestamp”)
constant(value=” “)
property(name=”hostname”)
constant(value=” “)
property(name=”msg”
regex.type=”ERE”
regex.submatch=”1”
regex.expression=”\[(.+)\]--end”
regex.nomatchmode=”BLANK”
)
constant(value=” “)
property(name=”msg”
regex.type=”ERE”
regex.submatch=”1”
regex.expression=”\[.+\](.+)$--end”
regex.nomatchmode=”BLANK”
)
constant(value=”\n“)
}
当我解析conf文件时,它抱怨转义字符。
tobias@ubuntutest:~$ sudo rsyslogd -N1
rsyslogd: version 7.4.4, config validation run (level 1), master config /etc/rsyslog.conf
rsyslogd: error during parsing file /etc/rsyslog.d/41-AP.conf, on or before line 20: invalid character '"' in object definition - is there an invalid escape sequence somewhere? [try http://www.rsyslog.com/e/2207 ]
rsyslogd: error during parsing file /etc/rsyslog.d/41-AP.conf, on or before line 20: invalid character '\' in object definition - is there an invalid escape sequence somewhere? [try http://www.rsyslog.com/e/2207 ]
rsyslogd: error during parsing file /etc/rsyslog.d/41-AP.conf, on or before line 20: invalid character '.' in object definition - is there an invalid escape sequence somewhere? [try http://www.rsyslog.com/e/2207 ]
rsyslogd: error during parsing file /etc/rsyslog.d/41-AP.conf, on or before line 20: invalid character '*' in object definition - is there an invalid escape sequence somewhere? [try http://www.rsyslog.com/e/2207 ]
rsyslogd: error during parsing file /etc/rsyslog.d/41-AP.conf, on or before line 20: invalid character '\' in object definition - is there an invalid escape sequence somewhere? [try http://www.rsyslog.com/e/2207 ]
rsyslogd: error during parsing file /etc/rsyslog.d/41-AP.conf, on or before line 20: syntax error on token ']' [try http://www.rsyslog.com/e/2207 ]
rsyslogd: CONFIG ERROR: could not interpret master config file '/etc/rsyslog.conf'. [try http://www.rsyslog.com/e/2207 ]
rsyslogd: run failed with error -2207 (see rsyslog.h or try http://www.rsyslog.com/e/2207 to learn what that number means)
我不明白为什么,正则表达式经过验证没有任何错误。http://www.rsyslog.com/e/2207什么也没给出。有任何想法吗?