There are two ways to remove cruft from main log.
- Conditional logging.
- Separate (sub)domains for media and feeds.
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