[thelist] Re: Apache & Logging

Kevin Martin kevin at brasscannon.net
Mon Dec 10 14:00:24 CST 2001


Quoth "Michael Buffington" <mike at stirlingbridge.com>
> 
> I'm looking for a good tutorial on how to set up logging on Apache for
> multiple virtual hosts. I've seen a few, but they mostly mirror what the
> Apache docs state (the Apache docs work as a good sedative for me).
> 
> Examples of the httpd.conf file wouldn't hurt either. Thanks!

Here's how I do it -- I much prefer to have everything go to one log
file, since having a log per virtual  host can use up too many file
handles:

# NAMED VIRTUAL HOSTS
# How to a) log access by virtual host name and b) report it in Analog
#
# STEP ONE:
# in the Apache httpd.conf, add this custom LogFormat:

LogFormat "%h %l %u %t %v \"%r\" %>s %b \"%{Referer}i\" 
\"%{User-Agent}i\"" custom

# the %v will cause the log to record virtual host requests by name -- 
example:
                                              vvvvvvvvvvvvvvvv
212.135.14.4 - - [05/Jun/2001:03:23:40 -0400] handsonhowto.com "GET 
/lan101.html HTTP/1.0" 200 23021 "-" "Mozilla/4.0 (compatible; 
MuscatFerret/2.0; http://www.webtop.com/)"
                                             vvvvvvvvvvvvvvvvv
213.82.31.3 - - [05/Jun/2001:05:43:02 -0400] www.silkpurse.net "GET / 
HTTP/1.1" 200 835 "http://www.agora.stm.it/M.Bessone/link.htm" 
"Mozilla/4.0 (compatible; MSIE 5.5; Windows 95)"

# STEP TWO:
# To use this added field in Analog, edit analog.cfg (after the commented 
# "LOGFILE" line, add this "APACHELOGFORMAT" line - you can place the %v
# wherever you want, but I recommend this format):

APACHELOGFORMAT (%h %l %u %t %v \"%r\" %>s %b \"%{Referer}i\" 
\"%{User-Agent}i\")

# Then add this line to enable VHOST reporting:
VHOST on

Hope that helps!
-- 
Kevin Martin <evolt at brasscannon.net>





More information about the thelist mailing list