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 would like my access_log to list the host name that the client is requesting (e.g. when requesting http://www.example.com/test I should see "www.example.com" in the log). The only thing I have found so far is to use %v in the LogFormat directive, but this only gives "the canonical ServerName of the server serving the request" (as described by Apache at http://httpd.apache.org/docs/2.0/mod/mod_log_config.html#formats). This does not help me for requests that use a hostname that is not specified in a ServerName directive.

Is there any way to log the requested hostname?

Thanks

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

%...{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.

So in your case that would be

%{Host}i

share|improve this answer
add comment

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.