How to disable apache logging when accessing certain directories?
How do I get apache to prevent http requests from being logged on a directory basis? I want to do something alike
<IfModule mod_userdir.c>
UserDir public_html
<Directory /home/*/public_html/nolog>
Options NoAccessLog
</Directory>
</IfModule>
You can set an environment flag whenever a specific URL is requested and filter logging based on that:
<IfModule mod_userdir.c>
UserDir public_html
SetEnvIf Request_URI "/nolog" dontlog
CustomLog /var/log/apache2/useraccess_log combined env=!dontlog
</IfModule>
All the related reading can be found at http://httpd.apache.org/docs/2.2/env.html Section "Using Environment Variables - Conditional Logging"
What these two lines do is, whenever a Client requests a URL that contains the string "/nolog" it sets the Environment Variable dontlog.
In the next line the option "env=!dontlog" tells the CustomLog directive to log Client access unless the variable dontlog is set. The ! negates the directive. If you would leave the ! so that it reads "env=dontlog" than it would only log access to paths that have "/nolog" in the requested URL.
EDIT: I removed the ^ in the "/nolog" regexp to work with your example and added some more explanation.