【问题标题】:Can't configure the rewrite log无法配置重写日志
【发布时间】:2012-12-05 22:09:58
【问题描述】:

我想启用重写日志来调试一些给我带来问题的重写规则。所以我在 httpd.conf 文件的末尾添加了这些行:

<IfModule mod_rewrite.c>
   RewriteLog "/logs/rewrite.log"
   RewriteLogLevel 4
</IfModule>

接下来我做的是重新启动 Apache。但是,它会导致错误,并且不会启动。这是我在 XAMPP 控制面板中得到的:

13:14:56  [Apache]    Error: Apache shutdown unexpectedly.
13:14:56  [Apache]    This may be due to a blocked port, missing dependencies, 
13:14:56  [Apache]    improper privileges, a crash, or a shutdown by another method.
13:14:56  [Apache]    Check the "/xampp/apache/logs/error.log" file
13:14:56  [Apache]    and the Windows Event Viewer for more clues

我在 error.log 中没有任何线索。实际上发生这个错误时没有生成任何行。

我还尝试将 RewriteLog 行更改为使用绝对路径:

RewriteLog "c:\xampp\apache\logs\rewrite.log"

你能帮帮我吗?

【问题讨论】:

    标签: apache mod-rewrite httpd.conf apache2.4 rewritelog


    【解决方案1】:

    Apache 的哪个版本?

    在 2.4 中,RewriteLog* 指令不再存在,因为日志记录已被重写。在这种情况下,您应该将 mod_rewrite.c:trace3 附加到您的 LogLevel 行,其中 traceX 是详细级别 (8 >= X >= 1)。输出将写入 Apache 标准错误日志 (ErrorLog)。

    您是否也可以运行以下命令: httpd -t(语法检查)然后 httpd -w(运行 Apache 但保持打开控制台,用作标准错误)

    【讨论】:

    • 是的,我的服务器是 Apache 2.4。我已经看到我的默认配置是LogLevel warn,所以我应该这样做吗?:LogLevel warn mod_rewrite.c:trace3
    • 是:LogLevel warn mod_rewrite.c:trace3warn 是所有模块的默认详细级别,您将 mod_rewrite 的级别重新定义为更高的值
    • 完美!!谢谢,它有效!还有一个问题:除了 Apache 2.4 中的错误日志之外,是否可以创建自己的重写日志?
    • 不幸的是,没有。这是这种新“方式”的“副作用”。
    • 好的,没问题。对我来说,让它工作就足够了。再次感谢和最好的问候! :)
    猜你喜欢
    • 1970-01-01
    • 2012-06-24
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-18
    相关资源
    最近更新 更多