Issue5

Title Logging configuration suitable for MirrorBrain needs to be documented
Priority feature Status in-progress
Superseder Nosy List poeml
Assigned To poeml Keywords docs

Created on 2009-10-06.20:52:46 by poeml, last changed by poeml.

Messages
msg40 (view) Author: poeml Date: 2009-10-26.19:45:16
(notes copied from a mail, which might be suitable starting point)


In the (default) access log, Apache logs the HTTP status code directly
after the URL. So you see 
	"GET /url/... HTTP/1.1" 200 ...
for a request that was answered with a "200 OK" reply. 

For a redirect however, you would see a reply with 
	"GET /url/... HTTP/1.1" 302 ...
where the number is from "302 Found", a reply that comes with a Location
header containing the URL to be followed.

So to verify that MirrorBrain is redirecting correctly, you could look
into the access_log in the first place. If the access_log contains only 
"200" responses, no redirects happen. 

For the record, let me mention an additional way to check for redirects.
You can look at the protocol level with "curl -sI <URL>", which will
make the server responses visible (only the header lines due to the -I).
Example screenshot (of a working redirect): 
http://mirrorbrain.org/static/images/screenshots/redirect.jpg
With a browser like Firefox, it is harder to notice if a redirect
happens.



With some Apache configuration, MirrorBrain allows logging several more
details out of the box, that complement the normal access log:

- which mirror a client was sent to
- data about client origin: country, continent, autonomous system number
 and network prefix.
- the reason why a particular mirror was selected
- size of the file in question
- files for which no mirror was found
- (with Apache's native logging means) things like the number of bytes
 actually transferred, byterange headers requested by the client or
 other headers

All these could be logged conditionally, using Apache's SetEnvIf
directive combined with "CustomLog env=....".


Here's an example for defining a new LogFormat which logs all of the
above. The format is identical to the "access log" format, but with
additional data added at the end of the log lines:

# In order to log the mirror we redirected to, we use the
# %{X-MirrorBrain-Chose-Mirror}o logging variable to log that headers
# content
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \
%{X-MirrorBrain-Mirror}o r:%{MB_REALM}e \
%{MB_CONTINENT_CODE}e:%{MB_COUNTRY_CODE}e ASN:%{ASN}e P:%{PFX}e \
size:%{MB_FILESIZE}e %{Range}i" combined_redirect

To use the newly defined log format, you use "combined_redirect" with
the CustomLog directive of the virtual host in question, instead of the
usually defined "combined" log format.
msg18 (view) Author: poeml Date: 2009-10-06.22:43:26
See http://mirrorbrain.org/archive/mirrorbrain/0023.html
msg15 (view) Author: poeml Date: 2009-10-06.20:52:46
A decent logging config needs to be described.
History
Date User Action Args
2009-10-26 19:45:35poemlsetstatus: chatting -> in-progress
2009-10-26 19:45:16poemlsetmessages: + msg40
2009-10-06 22:43:26poemlsetstatus: unread -> chatting
messages: + msg18
2009-10-06 20:52:46poemlcreate