【发布时间】:2015-03-29 02:22:53
【问题描述】:
我已经看到有关如何不将 404 错误记录到错误日志的问题,这是相反的。
由于某种原因,我的 apache 安装没有将 404 错误记录到我的错误日志(或我的访问日志)。我已正确设置错误日志并看到错误,但是当我访问不存在的页面时,我只会收到 404 错误 - access(但不是 404 错误)显示在访问中.log,但我在错误日志中看不到任何内容(例如,很难调试为什么某些页面没有显示)。
关于日志的我的 apache (2.4.7) conf 设置(按照设置的顺序)是:
ErrorLog ${APACHE_LOG_DIR}/error.log
ErrorLog logs/error_log
LogLevel warn # Though I've tried setting this to debug
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\"" common
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
CustomLog logs/access_log common
LogFormat "%{HOST}i %h %l %u %t \"%r\" %s %b \"%{User-Agent}i\"" vcommon
CustomLog logs/access_log vcommon
所以我认为唯一与错误日志相关的(忽略覆盖的设置)是:
ErrorLog logs/error_log
LogLevel warn # Though I've tried setting this to debug
【问题讨论】:
-
我们可以查看您的
log4j.properties文件吗? -
我没有使用 Java 或 log4j
-
我遇到了完全相同的问题。任何人的想法?我的 .htaccess 文件中有这个:ErrorDocument 404 /404/index.php 重定向到友好页面。这样做会阻止任何 404 错误的记录吗?
-
这里的小更新。我部分错了。 404 出现在我的访问日志中,但没有出现在错误日志中。我目前的怀疑是,通过使用 ErrorDocument 处理程序来显示自定义 404 页面,可以防止将错误写入错误日志。如果是这样的话,我发现很难在任何地方找到这种效果。
-
我没有使用 ErrorDocument,尽管我可以看到如何将 404 重定向为错误。无论哪种方式,我的设置都不是这种情况。
标签: apache logging http-status-code-404