17

I'd like to enable the rewrite log to debug some rewrite rules that are giving me problems. So I added these lines at the end of my httpd.conf file:

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

Next thing I did was restart Apache. It causes an error however, and won't start. This is what I get in the XAMPP Control Panel:

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

I don't get any clue in error.log though. In fact no line is generated when this error occurs.

I also tried changing the RewriteLog line to use an absolute path:

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

Could you please help me?

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
Luis Martin
  • 910
  • 3
  • 14
  • 31

1 Answers1

31

Which version of Apache?

In 2.4, RewriteLog* directives don't exist anymore as logging has been rewritten. In this case, you should append mod_rewrite.c:trace3 to your LogLevel line where traceX is the level of verbosity (8 >= X >= 1). The output will be written to Apache standard error log (ErrorLog).

Could you also run these commands: httpd -t (syntax checking) then httpd -w (run Apache but hold open the console, used as stderr)

julp
  • 3,860
  • 1
  • 22
  • 21
  • 1
    Yes, my server is Apache 2.4. I've seen my default config is `LogLevel warn`, so should I do this?: `LogLevel warn mod_rewrite.c:trace3` – Luis Martin Dec 19 '12 at 10:36
  • 2
    yes: with `LogLevel warn mod_rewrite.c:trace3` warn is the default verbosity level for all modules and you redefine mod_rewrite's level to a higher value – julp Dec 19 '12 at 10:44
  • Perfect!! Thank you, it works! Just one more question: is it possible to create your own rewrite log apart from the error log in Apache 2.4? – Luis Martin Dec 19 '12 at 10:50
  • 3
    Unfortunately, no. This is a "side effect" of this new "way". – julp Dec 19 '12 at 10:58
  • ok, no problem. For me it's enough to have it working. Thanks again and best regards! :) – Luis Martin Dec 19 '12 at 11:00
  • Putting this line in `apache.conf` doesn't actually work, sadly. – AnnoyinC Sep 20 '21 at 11:23