I am trying to set a SetEnvIf variable in apache2 and exclude it in CustomLog in order to stop my logs from filling up. I want to match a regex and also specific IPs.
I tried to follow the instructions listed at the site below, but it does not seem to be working. http://www.howtoforge.com/setenvif_apache2
Noob alert: The site doesn't specify where to put the SetEnvIf statement, so I put them in apache2.conf and also /sites-available/default.
Here is an example of what I want to filter in access.log:
x.x.x.x - - [06/Sep/2014:15:02:35 -0500] "HEAD /dir/dir2/file1/file2.gif HTTP/1.1" 200 224 "-" "-"
127.0.0.1 - - [06/Sep/2014:15:02:30 -0500] "GET /foo1/foo2.php? HTTP/1.0" 200 28956 "-" "Wget/1.12 (linux-gnu)"
So in apache2.conf and /sites-available/default, i put this:
SetEnvIf Request_URI "HEAD /dir/" dontlog
SetEnvIf Request_Addr "127\.0\.0\.1" dontlog
SetEnvIf Request_Addr "::1" dontlog
And added env=!dontlog to the existing /default/CustomLog entry:
CustomLog ${APACHE_LOG_DIR}/access.log combined env=!dontlog
I then executed apachectl graceful .
Nothing is changing.