Apr
2
Logging the domain with Apache wildcard virtual hosts
If you have an Apache virtual host set up to respond to a number of different domains, the two typical access log configurations (common and combined) do not include domain information. So you can see what resource is being accessed, but not for which domain. This becomes significant if you are serving different content based on the domain, as we do with Blueprint.
We use the NCSA combined log format. Adding the domain information to this format is as simple as plucking it from the request headers: "{Host:}i". To retain compatibility with the standard ‘combined’ format, we replace the superfluous “user” item in the format with the domain, like this:
CustomLog access_log "%h %l \"%{Host}i\" %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""