Using %v in Apache LogFormat definition matches ServerName instead of specific vhost requested

Posted by Graeme Donaldson on Server Fault See other posts from Server Fault or by Graeme Donaldson
Published on 2010-04-19T10:22:20Z Indexed on 2012/06/19 15:18 UTC
Read the original article Hit count: 335

Filed under:
|

We have an application which uses a DNS wildcard, i.e. *.app.example.com. We're using Apache 2.2 on Ubuntu Hardy. The relevant parts of the Apache config are as follows.

In /etc/apache2/httpd.conf:

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

In /etc/apache2/sites-enabled/app.example.com:

ServerName app.example.com
ServerAlias *.app.example.com
...
CustomLog "|/usr/sbin/vlogger -s access.log /var/log/apache2/vlogger" vlog

Clients access this application using their own URL, e.g. company1.app.example.com, company2.app.example.com, etc.

Previously, the %v in the LogFormat directive would match the hostname of the client request, and we'd get several subdirectories under /var/log/apache2/vlogger corresponding to the various client URLs in use.

Now, %v appears to be matching the ServerName value, so we only get one log under /var/log/apache2/vlogger/app.example.com. This breaks our logfile analysis because the log file has no indication of which client the log relates to.

I can fix this easily by changing the LogFormat to this:

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

This will use the HTTP Host: header to tell vlogger which subdirectory to create the logs in and everything will be fine.

The only concern I have is that this has worked in the past and I can't find any indication that this has changed recently.

Is anyone else using a similar config, i.e. wildcard + vlogger and using %v? Is it working fine?

© Server Fault or respective owner

Related posts about apache2

Related posts about vlogger