httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Skea <>
Subject Re: [PATCH] Multiple env test for CustomLog directives in 1.3.26 (mod_log-config.c)
Date Sat, 10 Aug 2002 00:56:11 GMT
At 23:27 09/08/02, Joshua Slive wrote:

>Alan Skea wrote:
>>I got a bit frustrated by the lack of flexibility in the mod_log_config CustomLog
directive.  What I wanted was to make logging conditional on multiple environment variables
that get set by different modules, and also to be able to make logging behaviour depend on
the value of the variables rather than just their presence or absence.
>>I decide that the appropriate way to do this was to extend the syntax of the CustomLog
directive as follows:
>I don't believe this is necessary.  You didn't present a specific use case, but let me
try an example:
>Log only if var1 is set to yes and var2 is not set to no:
>SetEnvIf var1 yes logme
>SetEnvIf var2 no !logme
>CustomLog logs/access_log combined env=logme
>If that doesn't solve your problem, please be more specific about what the problem is.

I don't think SetEnvIf quite does it.  In one module I extract a session tracking token from
the URI and set it into an env var.  If this var is present then I want to use a particular
log format.  I also started looking at a module called robotcop the other day.  It monitors
accesses to the robots.txt file to determine if a request comes from a robot.  Without getting
into the merit or demerits of a stateful module I was trying out logging the robot requests
to a completely different logfile.  In addition there are a number of states that robotcop
can be in that might also affect how (or if) I would want to log the request.

So the upshot is that I have two modules that set env variables and at least four different
behaviours depending on the values of those variables.  Here's what I want to achieve using
the syntax I proposed:

        CustomLog logs/robotlog session_fmt env=SESSION,ROBOTCOP
        CustomLog logs/userlog session_fmt env=SESSION,!ROBOTCOP
        CustomLog logs/robotlog combined env=!SESSION,ROBOTCOP
        CustomLog logs/userlog combined env=!SESSION,!ROBOTCOP

There was a moment that I considered further qualifying the robotcop logging based on other
internal robotcop state.  This would mean setting different env vars for each different logging
behaviour, or getting the logging mechanism to do at least allow exact matching on the value
of an env var.  Anyway that idea went out the window for now - at least till I've decided
if robotcop is really something I want to use, however the point is it would have further
complicated the logging setup.  It seems to me that the right place to conjunct env vars for
logging is in the logging directives without some place where different env vars can be tested
within the same directive, the above isn't possible.

 -_-_ Alan.

  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message