Disable Apache 2.x logging for favicon.ico or apple-touch-icon

Submitted by luxian on Wed, 07/19/2017 - 08:43

One of the features I like in nginx is the ability to disable logging for certain paths. For example whenever a browser sends a requests for a favicon.ico which doesn't exists the web server will respond with a 404 error but will also write the request to access_log and error_log -- which is totally useless. Most of the time nobody cares about these favicon and apple-touch-icon requests, so logging them is quite useless and is just a waste of CPU cycles and IO throughput.

If you use nginx is quite easy to disable logging for them with something like

location = /favicon.ico { 
  access_log off; 
  log_not_found off; 

But Apache is more tricky to set up, the log configuration is not very straightforward. So here is what I was able to find on this subject after some hours of searching.