404错误未出现在Apache error.log中 [英] 404 error doesn't appear in Apache error.log
问题描述
如果访问者遇到404错误,则不会在apache error.log
中写入任何内容.在访问日志中,它看起来像这样:
If a visitor gets 404 error, nothing is written in apache error.log
. In access log it appears like this:
GET /qqq HTTP/1.1" 404 409 "-"
error.log
中没有任何内容.我已经尝试了有关LogLevel
的所有内容.据我了解,这是因为404页面是自定义页面,例如
And nothing in error.log
. I have tried everything about LogLevel
. As I understand, it is because that 404 page is custom page like
ErrorDocument 404 /new404.html
但是我在所有/etc/apache2
中搜索文件中的文本"404",但没有找到任何内容(而不是注释行).可能是什么问题?或者,也许我可以以某种方式禁用.htaccess
文件中的自定义404页面?或以其他任何方式在error.log
中显示404错误?
But I run search through all /etc/apache2
for text "404" in files and nothing was found there (instead of commented lines). What can be the problem? Or maybe I can somehow disable custom 404 page in .htaccess
file? Or any other ways to display 404 errors in error.log
?
推荐答案
作为提交 Apache错误,从Apache 2.4.1开始将404从错误降级为信息级别,这是合理的:
As the person who filed the Apache bug which demoted 404 from Error to Info level as of Apache 2.4.1, here's the justification:
在开放到Internet的生产HTTP服务器中,始终会发生404错误.恶意软件,扫描仪脚本和各种各样的其他东西都会探测Web服务器是否存在漏洞,或者仅仅是因为它们可以探测到这些漏洞,而这些东西都将触发错误,如果设置了适当的错误级别,这些错误最终将被记录在某个地方.
In production HTTP servers open to the Internet, 404s happen all the time. Malware, scanner scripts, and all sorts of other things probe Web servers for vulnerabilities or just because they can, and these things would all trigger errors which will end up being logged somewhere if the appropriate error level is set.
大多数生产Web服务器的管理员都满意在访问日志中看到404(该日志与200s和30x重定向一起记录),并希望在错误日志中看到真正的服务器问题-他们可以控制的事情- .在某些服务器中,在error.log中记录404日志可能会导致大量日志垃圾邮件,从而淹没了需要管理员注意的合法问题.
Most production Web server admins are content with seeing 404s in their access logs (which are logged right alongside 200s and 30x redirects), and want to see real server problems -- things they have control over fixing -- in the error log. The logging of 404s in error.log can, in some servers, be so much log spam that it drowns out legitimate problems needing the administrator's attention.
404是一个 content 问题,而不是一个 server 问题.因此,我的建议是在您的access.log(或等效文件)中查找它们.如果您确实要在error.log中记录与 content 相关的问题,则需要设置LogLevel core:info
.这将为您提供404,以及其他一些与内容相关的错误消息.
404 is a content issue, not a server issue. So my recommendation is to look in your access.log (or equivalent) for them. If you really want content related issues logged in error.log, you need to set LogLevel core:info
. This will give you 404s there, and a few other kinds of content-related error messages too.
这篇关于404错误未出现在Apache error.log中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!