我想在rsyslog服务器中构建来自我的D-Link DAP-2310的日志。它有一个非标准的日志格式,我的想法是用一个rsyslog模板中的正则表达式来修复它。当我用rsyslogd -N1解析rsyslog.conf时,结果真的令人沮丧。rsyslog模板 - 在正则表达式中解析失败
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文件抱怨转义字符。
[email protected]:~$ 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不给。有任何想法吗?
这个'\\ [(。+)\\]'和这个'\\ [。+ \\](。+)'工作吗? – Diego