[Mod_log_sql] Logging environment variables

Mike Cardwell mod_log_sql at blubbernet.com
Thu Nov 24 11:22:37 EST 2005

* on the Thu, Nov 24, 2005 at 10:51:52AM -0500, Edward rudd 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:
> [snip]
> I actually do have this kind of feature on my todolist.  Not the
> environment variables, but rather the munging of hostnames, so only
> foo.com can be logged, and also logging anything.anything.foo.com and
> anything.foo.com into foo.com's single long table when mass virtual
> hosting is on in mod_log_sql.

I think mod_log_sql would be a lot more powerful if you were able to
specify column names to be filled by the contents of Environment
variables eg:

LogSQLEnvVar virtual_host "VHOST"
LogSQLEnvVar remote_port  "REMOTE_PORT"

Using a mod_rewrite map you can fill in those env variables with almost
any data you can think of, and then log them to the database in a column
name of your choice. Granted, that's a very specialised feature request
that most people wouldn't require.

Technically, you could drop altogether LogSQLTransferLogFormat if this
were the case.

>> 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" );
> That'll do it as a quick solution

I know it's dirty :)

By the way, I've had 30 Apache1.3 boxes using mod_log_sql in testing
performing a sustained ~900 mysql inserts a second without causing any
noticable load. I'm impressed. Well done.


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

More information about the Mod_log_sql mailing list