无法配置重写日志

Lui*_*tin 17 apache mod-rewrite httpd.conf apache2.4 rewritelog

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

<IfModule mod_rewrite.c>
   RewriteLog "/logs/rewrite.log"
   RewriteLogLevel 4
</IfModule>
Run Code Online (Sandbox Code Playgroud)

我做的下一件事是重启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
Run Code Online (Sandbox Code Playgroud)

我在error.log中没有任何线索.实际上,当发生此错误时,不会生成任何行.

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

RewriteLog "c:\xampp\apache\logs\rewrite.log"
Run Code Online (Sandbox Code Playgroud)

请你帮助我好吗?

jul*_*ulp 32

哪个版本的Apache?

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

你也可以运行这些命令:( httpd -t语法检查)然后httpd -w(运行Apache但是保持打开控制台,用作stderr)

  • 很不幸的是,不行.这是这种新"方式"的"副作用". (3认同)
  • 是:使用`LogLevel warn mod_rewrite.c:trace3` warn是所有模块的默认详细级别,并将mod_rewrite的级别重新定义为更高的值 (2认同)