Forum Moderators: phranque

Message Too Old, No Replies

seperate log files for subdomains

         

davadoo

8:37 am on Mar 13, 2005 (gmt 0)

10+ Year Member



Hi all

I'm running apache 2 on windows. I have the following virtual host directive in my http.conf :


NameVirtualHost *:80

<VirtualHost *:80>
ServerName *.mydomain.com
DocumentRoot c:/web/mydomain/public/

<Directory c:/web/mydomain/public/>
Options ExecCGI FollowSymLinks
AllowOverride all
Allow from all
Order allow,deny
</Directory>
</VirtualHost>

my php application parses the request headers and displays custom content based on the subdomain.

However, I was wondering if it's possible to maintain a seperate access log for each subdomain even though there's only one virtual host? Would it be possible to have apache create an access log for each subdomain? so requests for foo.mydomain.com get logged to foo.log and bar.mydomain.com would go to bar.log etc..

failing that, would it be possible to add the subdomain to the access logs using a CustomLog directive?

thanks for your help

dave

py9jmas

9:49 am on Mar 13, 2005 (gmt 0)

10+ Year Member



[httpd.apache.org...]
explains some of the pros and cons of logging each vhost to its own logs. I would expect the example log format given would work even if all the requests were served from the same <virtualhost> definition. %v is the "canonical ServerName of the server serving the request". See also
[httpd.apache.org...]

davadoo

10:13 am on Mar 13, 2005 (gmt 0)

10+ Year Member



thanks but %v logs *.mydomain.com as the ServerName, I need some way to log the actual subdomain used in the request

py9jmas

11:17 am on Mar 13, 2005 (gmt 0)

10+ Year Member



Ok then, another idea. One of the log format codes is
%...{Foobar}i The contents of Foobar: header line(s) in the request sent to the server.

so you could try %{Host}i to log the contents of the Host: HTTP header.