[Zope] logging for virtual hosts
zope@concision.com
zope@concision.com
10 Nov 2000 20:49:57 -0500
Well, I tried the source hacking approach and seem to have found
success with relatively little pain.
In ZServer/medusa/http_server.py, the "log" method of the class
"http_request" can be modified to report the request hostname which
is readily available via the get_header method in the same class. Here
is my modified "log" method:
def log (self, bytes):
user_agent=self.get_header('user-agent')
if not user_agent: user_agent=''
referer=self.get_header('referer')
host=self.get_header('host')
if not referer: referer=''
self.channel.server.logger.log (
self.channel.addr[0],
' - - [%s] "%s" %d %d "%s" "%s" %s\n' % (
self.log_date_string (time.time()),
self.request,
self.reply_code,
bytes,
referer,
user_agent,
host
)
)
Note that this puts the request hostname at the end of the log
entry.