How to impose two conditions at once for Apache CustomLog?

Solution 1:

The reqenv function must be compared against something, you cannot just check for the environment variable to be set or not as your code tries to. I admit the error message is not particularly enlightening :-)

The following should work for you:

SetEnvIf Request_URI ^/(img|js|css|thumb|banner) static=yes
SetEnvIf Remote_Addr "127.0.0.1" dontlog=yes

CustomLog logs/access_log myCustom expr=!(reqenv('static')=='yes'||reqenv('dontlog')=='yes')