Bug 49844

Summary: No documentation on the logging format of RewriteLog
Product: Apache httpd-2 Reporter: Stefan Nowak <p.org>
Component: DocumentationAssignee: HTTP Server Documentation List <docs>
Status: RESOLVED FIXED    
Severity: enhancement    
Priority: P2    
Version: 2.2-HEAD   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Stefan Nowak 2010-08-30 08:12:02 UTC
I could not find any OFFICIAL (=within Apache domains) documentation/explanation of the logging format generated through the directive "RewriteLog", nor useful INOFFICIAL (=external) resources.

The first place where I would expected it:
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritelog

Neither was I lucky at:
http://wiki.apache.org/httpd/Logs
http://httpd.apache.org/docs/2.2/mod/mod_log_config.html

And googling for various combinations of these key words:
Format understand explained Apache RewriteLog rewrite log
also did not deliver useful results! Only unanswered forum questions such as:
http://stackoverflow.com/questions/2023959/understanding-apache-rewritelog

Please add OFFICIAL documentation, and please meanwhile point me to an INOFFICIAL ressource, if you know any. Thanks!
Comment 1 ww.galen 2010-09-21 04:44:18 UTC
As a start, here's the printf format and description of the fields, extracted from mod_rewrite (http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/mappers/mod_rewrite.c?view=markup#l437):

"%s %s %s [%s/sid#%pp][rid#%pp/%s%s%s] %s%s%s%s"

  remote host,
  remote login name,
  HTTP user,

  HTTP host,
  virtual host ID (a memory address),

  request ID (a memory address),
  subrequest or initial request,
  count of internal redirects,

  directory (if from a per-directory rewrite),
  text

I'm not sure how best to write that up, since custom log formatting doesn't support some of those fields. It's approximately:

  %h %l %u [%V/sid#$sid][rid#$rid/(initial|subreq){/redir#$rcount}] {[perdir $dir]} $msg

"()" indicates grouping, "{}" indicates a field that may not be present, and "$" starts a field that doesn't have a custom log format specifier.
Comment 2 Stefan Nowak 2010-09-21 07:33:09 UTC
PROPOSAL FOR HOW TO WRITE UP THE DOCUMENTATION:
(How I, from the user perspective, would like to have it)

1) Log line format (as you wrote it)
2) Syntax annotations for (1) (as you wrote it)
3) A table which describes all the variable names, like at:
http://httpd.apache.org/docs/current/mod/mod_log_config.html#formats
4) Some sample lines, as examples are always good for understanding!


FURTHER QUESTIONS:

Q.1) My log lines, as generated by httpd 2.0.63, look a bit different than yours. I try to show you its syntax, using pseudo variables for the observed differences:

%h %l %u [$date] [%V/sid#$sid][rid#$rid/(initial|subreq)] {\($rcount\)} {[perdir
$dir]} $msg

[$date] A date with a formatting like [30/Aug/2010:16:14:34 +0200]
{\($rcount\)} The optional counter comes AFTER the square brackets which enclose the request ID group, within LITERAL round brackets, i.e. (3).

Q.2) How shall I interpret $rcount?
If I see this counter in a log line, does it mean:
a) This log line represents the N-th cycle of an internal redirect?
or
b) In the process logged in this line, httpd has used N internal redirects?

I ain't sure, as my subsequent log lines show $rcount numerical series like:
2,3,5,4,4,5,4,2,2,1,1,2,3,1,...
which are more logically explained by (b) as (a) would create numerical series, which steadily increase, and at the end fall back to 1, like:
1,2,3,1,2,3,4,1,2,1,2,3,...


THANKS for answers in advance!
Comment 3 Rich Bowen 2010-10-29 11:06:57 UTC
Moving docs bugs to docs@httpd.a.o ownership.
Comment 4 Rich Bowen 2010-10-31 18:49:49 UTC
Now that RewriteLog has gone away, this should probably go into the Logging section of the mod_rewrite docs. But we should probably add something in the 2.2 docs.
Comment 5 Rich Bowen 2010-10-31 19:04:07 UTC
Added in r1029508 for 2.2. Still trying to figure out what we need to do for trunk.
Comment 6 Stefan Nowak 2010-11-01 10:15:10 UTC
(In reply to comment #5)
Dear Richard: I had a look at the referenced documentation HTML file, and have to say that's an improvement to the old doc. It might need some overlooking as your format explanations partially differ/contradict with those of ww.galen (from comment #1)

1) "Virtual host ID" suffixed with "(a memory address)" in brackets, as this is a good extra information (if in deed true).
2) "Log entry severity level" contrary to ww.galen's "count of internal redirects"
3) "Directory (if from a per-directory rewrite)" missing before "Text error message"
Comment 7 Rich Bowen 2010-11-01 10:30:22 UTC
(In reply to comment #6)
> (In reply to comment #5)
> Dear Richard: I had a look at the referenced documentation HTML file, and have
> to say that's an improvement to the old doc. It might need some overlooking as
> your format explanations partially differ/contradict with those of ww.galen
> (from comment #1)

Thanks. I'll take another look at that.

> 1) "Virtual host ID" suffixed with "(a memory address)" in brackets, as this is
> a good extra information (if in deed true).

I don't think it is, but I'll investigate further. I left it out specifically because I don't think it's true.

> 2) "Log entry severity level" contrary to ww.galen's "count of internal
> redirects"

It's the log entry severity level. It corresponds to the value set in RewriteLogLevel. It is not a count of internal redirects.

> 3) "Directory (if from a per-directory rewrite)" missing before "Text error
> message"

Yeah. Things do look a little different in a per-directory rewrite. I'll try to clarify that.
Comment 8 Rich Bowen 2010-11-04 11:17:32 UTC
having looked at the code, I think that what we have is correct and complete. The log message is free-form text, and as such I'm not sure we want to document all possible permutations in this page.