Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an Apache 2.2 VirtualHost with a *.domain.com 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 *.domain.com entries, not the actual vhost that was asked for.

Anyone know how to do this?

share|improve this question

1 Answer 1

up vote 2 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 http://httpd.apache.org/docs/2.2/mod/mod_log_config.html

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

Your Answer

 
discard

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.