You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Alan Skea <sk...@acm.org> on 2002/08/10 02:56:11 UTC

Re: [PATCH] Multiple env test for CustomLog directives in 1.3.26 (mod_log-config.c)

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.
>
>Joshua.

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.

Re: [PATCH] Multiple env test for CustomLog directives in 1.3.26 (mod_log-config.c)

Posted by JAKE&JEN MCGRATH <je...@lakesplus.com>.
remove me from maillist plz
----- Original Message -----
From: "Alan Skea" <sk...@acm.org>
To: <de...@httpd.apache.org>
Sent: Friday, August 09, 2002 5:56 PM
Subject: Re: [PATCH] Multiple env test for CustomLog directives in 1.3.26
(mod_log-config.c)


> 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.
> >
> >Joshua.
>
> 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.
>


Re: [PATCH] Multiple env test for CustomLog directives in 1.3.26 (mod_log-config.c)

Posted by Joshua Slive <jo...@slive.ca>.
Alan Skea wrote:

> 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

SetEnvIf SESSION .+ robot_session
SetEnvIf ROBOTCOP "" !robot_session
SetEnvIf SESSION .+ user_session
SetEnvIf ROBOTCOP .+ !user_session
CustomLog logs/robotlog session_fmt env=robot_session
CustomLog logs/userlog session_fmt env=user_session
etc...

That might not be exactly it, but it should be close.

Now, the one thing that might cause problems is if the other modules set 
the variables too late for mod_setenvif to act on.  That would be 
another great use for the LogVariable directive that Ken and I were 
discussing a week or so ago.

Joshua.