How to log Apache requests conditionally

Today a small Apache configuration trick.

I’m using a fancy Amazon ELB ( to loadbalance (duh) two Apache nodes. In order to check whether the nodes are alive, the load balancer requests a static html page every few seconds. In my case this is elb-ping.html. Soon you will notice that this results in a your Apache acces.log being flooded with those ping requests.  Don’t worry, just tell Apache to log the requests conditionally.

To do so add the following lines to your virtualhost or apache configuration in general:

SetEnvIf Request_Uri “elb-ping.html” dontlog
CustomLog logs/access_log common env=!dontlog

Restart Apache and voila!