Conditional logging is a feature in apache web server which help you exclude some requests getting logged. By Syam Kumar R
There are two ways to remove cruft from main log.
You can exclude some requests, by setting environment variables using
SetEnvIf and adding
env=!variable clause to the
CustomLog directive in your apache configuration.
For example, if you have your images located in /images directory, you can exclude all requests to that directory from main log and if you want, log them in a separate log.
SetEnvIf Request_URI "^/images/" images CustomLog /logs/example.com/access.log combined env=!images CustomLog /logs/example.com/images_access.log combined env=images
See Conditional Logs in apache documentation.
This is what I do in my apache configuration:
SetEnvIf Request_URI "^/wordpress/" cruft SetEnvIf Request_URI "^/robots\.txt$" cruft SetEnvIf Request_URI "^/favicon\.ico$" cruft CustomLog /logs/example.com/access.log combined env=!cruft