nginx:[emerg]未知日志格式

时间:2017-10-26 16:19:28

标签: nginx logging

我试图排除pingdom出现在我的nginx访问日志上,但是收到错误:

nginx: [emerg] unknown log format "if=$excluded_ua" in /etc/nginx/nginx.conf:55
nginx: configuration file /etc/nginx/nginx.conf test failed

在我添加的配置中:

http {
...

  map $http_user_agent $excluded_ua {
         pingdom  0;
         ~Preload 0;
         default 1;
     }

        access_log /var/log/nginx/access.log combined if=$excluded_ua;

...
}

在纠正错误后,我仍然在访问文件中看到Pingdom条目。

94.247.174.83 - - [26/Oct/2017:22:02:56 +0100] "GET / HTTP/1.1" 200 14832 "-" "Pingdom.com_bot_version_1.4_(http://www.pingdom.com/)"

1 个答案:

答案 0 :(得分:3)

您可能需要包含log_format。默认值为"组合"。你能试试access_log /var/log/nginx/access.log combined if=$excluded_ua;吗?

http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log