【问题标题】:apache2.4.7 not logging "404 Not Found" pages to error.logapache2.4.7 未将“404 Not Found”页面记录到 error.log
【发布时间】: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


【解决方案1】:

终于想通了。

LogLevel 需要设置为“info”之类的内容 - 出于某种原因,用于记录 404 错误的“warn”的 LogLevel 不再这样做。

我不知道“调试”是否有效,我的问题暗示它不会,但我也意识到我在两个地方设置了 LogLevel。

【讨论】:

    【解决方案2】:

    好问题我不知道如何配置 apache 来做到这一点。通常要找到我的错误,我只需搜索我的访问日志。您可以使用 grep 或 awk 执行此操作。一个非常基本的命令是:

    grep ' 404 ' access.log
    

    【讨论】:

    • 404 not found 错误未记录到 either access.log 或 error.log(更新问题)
    猜你喜欢
    • 2015-03-25
    • 2014-02-16
    • 1970-01-01
    • 2018-12-03
    • 2014-01-26
    • 2021-03-07
    • 2021-07-25
    • 1970-01-01
    • 2018-04-18
    相关资源
    最近更新 更多