SetEnvIf do not log local network visits

SetEnvIf do not log local network visits

i’m trying to prevent apache from loging my own visits.. I’ve enabled SetEnvIf.so and added these lines to my vhost :


SetEnvIf Remote_Addr “192\.168\.1\.1” dontlog
SetEnvIf Remote_Addr “192\.168\.1\.5” dontlog
SetEnvIf Remote_Addr “192\.168\.1\.10” dontlog

There must be something I’m doing wrong since it still logs 192.168.1.10 (.1 and .5 too) to my access.log.
Should SetEnvIf be set somewhere else instead ?
Cheers.

Solutions/Answers:

Solution 1:

You should add env=!dontlog at the end of your CustomLog line.

Example (I also noticed the backslashes were not necessary):

<VirtualHost *:80> 
  ...
  SetEnvIf Remote_Addr "192.168.1.1" dontlog
  SetEnvIf Remote_Addr "192.168.1.5" dontlog
  SetEnvIf Remote_Addr "192.168.1.10" dontlog 
  ...
  CustomLog /var/log/apache2/mywebsite.access.log combined env=!dontlog
  ...
</VirtualHost>

References

Related:  what is this path 'tomcat/work/Catalina/localhost/_/org/apache/jsp' in tomcat?