禁用 404 错误日志记录

禁用 404 错误日志记录

问题描述:

在我的配置中,我使用:

In my configuration, I'm using:

error_page  404  /switch;

当我浏览到/testABC 时,我在日志中看到此错误:

When I browse to /testABC, I see this error in my log:

open() "/usr/local/nginx/html/www/testABC" failed (2: No such file or directory)

如何禁用此错误?我目前使用 404 作为网站功能的一部分.

How can I disable this error? I'm currently using the 404 as part of the site functionality.

如果您不想在 nginx 错误日志中显示 404 错误,log_not_found 是您要配置的指令.

If you don't want 404 errors to show in your nginx error logs, log_not_found is the directive you want to configure.

默认情况下,log_not_found 设置为on",这将在您的主错误日志中报告文件未找到错误.要关闭这些,只需执行以下操作:

By default, log_not_found is set to "on" which will report file not found errors in your main error log. To turn these off, just do:

log_not_found off;

来源:​​http://nginx.org/en/docs/http/ngx_http_core_module.html#log_not_found