我很难调试一个问题,我认为这可能有两个方面 - 两个单独程序中的问题。
主要问题是我在 Ubuntu 14.04 上将 nginx 记录到 syslog,如下所示:
access_log syslog:server=unix:/dev/log,tag=nginx,facility=local7,severity=info combined
Run Code Online (Sandbox Code Playgroud)
我希望能够过滤标记为 nginx 的消息,但没有那么幸运。
filter nginx { facility(local7) and tags("nginx") }
Run Code Online (Sandbox Code Playgroud)
将 and 更改为 or 可以工作,或者只需删除标签部分,因为设施过滤器工作正常。然而,标签过滤器不会。
所以,我想使用记录器进行测试并设置一个基本测试,如下所示:
template nginx { template("timestamp=${ISODATE} host=${HOST} tags=${TAGS} msgheader=${MSGHDR} ${MSG}\n"); template-escape(no); };
filter nginx { tags("nginx"); };
destination nginx { file("/tmp/nginx.log" template(nginx)); };
log { source(s_net); filter(nginx); destination(nginx); };
Run Code Online (Sandbox Code Playgroud)
--
$ logger -n localhost -P 10001 -t nginx -p local7.info -u /tmp/ignored testing 123
Run Code Online (Sandbox Code Playgroud)
我有一个源 s_net,在端口 10001 上侦听 UDP 以进行此测试。使用记录器,我通过 UDP 登录到该端口,使用 local7 …