You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have a webapp that serves multiple virtual hosts, the distinction which page was served for which host can't be recorded in the logfile, since there is currently no way to have the request.headers['host'] logged in access.log. For that, I made a one line addition to _cplogging.py/access(), in the atoms dict, I added an entry 'o' which allows one to log the Host the request came from.
With the patch, it becomes possible to do this:
log=app.log
log.access_log_format='%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s" %(o)s'
# Note the %(o)s at the end, which logs the Host
The patch, against trunk #2689:
--- _cplogging.py.2689 2010-08-21 11:37:19.000000000 +0200
+++ _cplogging.py 2010-08-21 11:37:41.000000000 +0200
@@ -217,6 +217,7 @@
'b': dict.get(outheaders, 'Content-Length', '') or "-",
'f': dict.get(inheaders, 'Referer', ''),
'a': dict.get(inheaders, 'User-Agent', ''),
+ 'o': dict.get(inheaders, 'Host', '-'),
}
for k, v in atoms.items():
if isinstance(v, unicode):
In my application, which serves hundreds to thousands of virtual domains, it will be undesirable to have so much logfiles lying around (and being open and written to simultaneously). I plan to do the log analysis later, based on selective extraction of log lines using the virtualhostname.
Furthermore, I do not propose a change to the logging format, only the ''possibility'' of using the virtual hostname in the log, if someone desires so (this requires explicit redefinition of app.log.access_log_format, if you leave that at the default you'll get a perfectly conforming CLF, even with my patch in place).
Thinking of it, it would be nice if access() could log any field from inheaders or outheaders, not just the pre-canned ones. But that's an exercise for later ;-)
Originally reported by: Anonymous
If you have a webapp that serves multiple virtual hosts, the distinction which page was served for which host can't be recorded in the logfile, since there is currently no way to have the request.headers['host'] logged in access.log. For that, I made a one line addition to _cplogging.py/access(), in the atoms dict, I added an entry 'o' which allows one to log the Host the request came from.
With the patch, it becomes possible to do this:
The patch, against trunk #2689:
Reported by motoom@xs4all.nl
The text was updated successfully, but these errors were encountered: