禁用 404 错误日志记录

编程入门 行业动态 更新时间:2024-10-23 21:30:34
本文介绍了禁用 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;

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

更多推荐

禁用 404 错误日志记录

本文发布于:2023-11-24 04:21:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623952.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   日志

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!