How can I log rewrite errors with apache 2.4?

Jelf

Active Member
Jun 26, 2016
36
4
58
Redmond
cPanel Access Level
Root Administrator
I have a RewriteRule that is not working. So I want to look at a log file for clues about what went wrong.

Here is what I tried.

I used WHM to edit the apache global config by setting log level to “debug” and Trace enable to “extended.
I saved the settings, remade and restarted apache.

Then I browsed to the page that should have redirected. The redirect did not work.

So I looked in the apache error.log file and searched for “rewrite”. That string was not found.

Any suggestions for how to get rewrite errors to show up in a log somewhere when using apache 2.4?
What documentation do I need to read? My googling was not turning up an answer.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
15,163
2,410
363
cPanel Access Level
Root Administrator
Hey there! According to the documentation, "debug" isn't a high enough log level to get details about rewrites:


"mod_rewrite offers detailed logging of its actions at the trace1 to trace8 log levels. The log level can be set specifically for mod_rewrite using the LogLevel directive: Up to level debug, no actions are logged, while trace8 means that practically all actions are logged."

This isn't the same as the "traceenable" option available in WHM, as that gives this functionality:


"This directive overrides the behavior of TRACE for both the core server and mod_proxy. The default TraceEnable on permits TRACE requests per RFC 2616, which disallows any request body to accompany the request. TraceEnable off causes the core server and mod_proxy to return a 405 (Method not allowed) error to the client."

You likely will need to manually modify the LogLevel directive to include things that aren't present in the WHM interface. While you can directly edit the Apache configuration to perform some testing, please note that any changes will be overwritten during the nightly update of the server.