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 an Apache 2.2 VirtualHost with a * ServerName. This is required for my scenario, all subdomains are handled with the same site.

Now, in the access log, I am trying to figure out a LogFormat variable (or way) that will let me log the asked for domain name. If I use the vhost_combined format, all I get in my access log is * entries, not the actual vhost that was asked for.

Anyone know how to do this?

share|improve this question
up vote 6 down vote accepted

You can use %{headername}i to put the contents of any header in the LogFormat directive, so %{Host}i will give you what the client put in the Host: header of the request, giving you exactly what you want.

See docs at

share|improve this answer
Awesome! That worked. Many thanks, Aleksandar. :) – Dhiraj Gupta Apr 19 '10 at 20:58

When you're using e.g. the vhost_combined Logformat:

CustomLog ${APACHE_LOG_DIR}/access.log vhost_combined

You can adapt vhost_combined by adding %{Host}i, e.g.

LogFormat "%v:%p %h %l %u %t %{Host}i \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
share|improve this answer

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.