如何在 Apache2 服务器上启用日志级别调试 [已关闭]

问题描述 投票:0回答:3

我的错误日志包含:

由于可能的配置错误,请求超出了 10 个内部重定向的限制。如有必要,请使用“LimitInternalRecursion”增加限制。使用“LogLevel debug”获取回溯。

我替换了 apache 配置文件上的日志级别:

LogLevel debug

重新启动后,我收到相同的错误消息,但没有所谓的“回溯”。据我了解,应该有 mod_rewrite 正则表达式生成的 10 行重定向。

在网上搜索后,我发现了很多关于 loglevel 和 mod_rewrite 的解释,但没有提到如何使 loglevel 调试工作。

有什么想法吗?

debugging apache2 error-logging
3个回答
84
投票

请注意,在较新的 Apache 版本上,

RewriteLog
RewriteLogLevel
已被删除,实际上现在在尝试启动 Apache 时会触发错误(至少在我使用 Apache 2.4.2 安装的 XAMPP 上):

AH00526:path/to/config/file.conf 的第 xx 行语法错误: 无效命令“RewriteLog”,可能拼写错误或由未包含在服务器配置中的模块定义`

相反,您现在应该使用通用

LogLevel
指令,级别为
trace1
trace8
。 “调试”没有在日志中为我显示任何重写消息。

示例:

LogLevel warn rewrite:trace3

有关官方文档,请参阅此处

当然这也意味着现在你的重写日志将被写入通用错误日志文件中,你必须自己整理它们。


40
投票

编辑:请注意,这个答案已经有 10 多年历史了。对于较新版本的 Apache,请参阅 sp00n 的回答。将此答案留给旧版本 apache 的用户。

对于旧版本 Apache:

为了调试 mod_rewrite 问题,您需要使用 RewriteLogLevel 和 RewriteLog:

RewriteLogLevel 3
RewriteLog "/usr/local/var/apache/logs/rewrite.log"

33
投票

您需要在新版本中使用

LogLevel rewrite:trace3
到您的
httpd.conf
http://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#logging

© www.soinside.com 2019 - 2024. All rights reserved.