Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a virtualhost setup with usecanonicalname off.

I have ServerName set and ServerAlias * in the virtualhost.

Using apache2's %v LogFormat string will only capture, and I'm trying to get it to capture so I can split logs accordingly.

LogFormat I'm currently using is

LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
share|improve this question

Using %{Host}i on your log format should give you the content of the "Host" header... which appears to be what you want.

Quote from the documentation:

%{Foobar}i - The contents of Foobar: header line(s) in the request sent to the server. Changes made by other modules (e.g. mod_headers) affect this. If you're interested in what the request header was prior to when most modules would have modified it, use mod_setenvif to copy the header into an internal environment variable and log that value with the %{VARNAME}e described above.

Hope this helps.

share|improve this answer

Why not just stick a separate CustomLog and ErrorLog directive into each virtual host definition?

<VirtualHost *:80>
ServerAdmin webmaster@place
DocumentRoot /var/www/hosted/place/root
AddHandler cgi-script .pl
CustomLog /var/www/hosted/place/logs/access_log combined
ErrorLog /var/www/hosted/place/logs/error_log
share|improve this answer
Because I don't want to set a new virtualhost for every subdomain we have, there's no need for it, they all share the same directives. I want to accept requests for * in one place, but have logs that say,, etc. – imaginative Nov 20 '09 at 15:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.