禁用404错误记录

iRy*_*ell 11 nginx

在我的配置中,我正在使用:

error_page  404  /switch;
Run Code Online (Sandbox Code Playgroud)

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

open() "/usr/local/nginx/html/www/testABC" failed (2: No such file or directory)
Run Code Online (Sandbox Code Playgroud)

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

jsd*_*ton 40

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

默认情况下,log_not_found设置为"on",它将报告主错误日志中的文件未找到错误.要解决这些问题,请执行以下操作:

log_not_found off;
Run Code Online (Sandbox Code Playgroud)

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