[Mod_log_sql] Logging environment variables

Mike Cardwell mod_log_sql at blubbernet.com
Thu Nov 24 09:56:49 EST 2005


* on the Thu, Nov 24, 2005 at 10:17:38AM +0000, Mike Cardwell wrote:

> I have a setup whereby there is a single virtual host that serves many
> sites. Rewrite rules are used to map a hostname to a path for the
> document root. I set the environment variable VHOST to be a slightly
> modified copy of HTTP_HOST.
> 
> Example:
> 
> If an incoming request comes in for foo.com or anything.foo.com
> or anything.anything.foo.com I want to only log foo.com. The VHOST
> variable is set to the correct value. I can log this to disk with:
> 
> LogFormat "%{VHOST}e %h %l %u %t \"%r\" %>s %b \"%{Referer}i\"
> \"%{User-Agent}i\"" vhost
> CustomLog /var/log/httpd/vhost-access.log vhost
> 
> But how the hell do I get mod_log_sql to use the value of VHOST rather
> than HTTP_HOST for the virtual_host column? I understand this may
> require patching mod_log_sql. if that's the case, can someone give me
> some pointers as I'm not a C programmer.

I've found a solution. In functions.h, in either extract_virtual_host or
extract_server_name depending on if you're using the 'v' or the 'V'
option, you simply change the contents of that subroutine to:

return apr_table_get( r->subprocess_env, "VHOST" );

Now I've got it working I think I'll write a more elegant solution.
That would have taken a C programmer 2 minutes to find and write ;)

Mike

-- 
Digital photo printing: http://www.fotoserve.com/



More information about the Mod_log_sql mailing list