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:
CustomLog <file|pipe> <format|nickname> [env=<env-tests>]
env-tests is a comma-separated set of tests as follows:
<env-var> # true if the variable exists
!<env-var> # true if the variable doesn't exist
<env-var>=<value> # true if the variable exists and has the given value
!<env-var>=<value> # true if the variable doesn't exist or doesn't have the given
value
Logging occurs only if all the tests are true. If you need a disjunction of more
complex expression then this can be achieved by using multiple CustomLog directives.
The advantage of this slightly curious systax is that it is fully backward compatible
with existing config files.
Patch is below.
-_-_ Alan Skea.
apache_1.3.26_mod_log_config.patch
Description: Binary data
