Conditional Logging in Apache

Often we find entries in our web logs which we seek to supress or block based on the fact that these entries may be skewing true statistics.

Most web log analysis software offers exclusion filters to block numerous types of entries. However, this can also be done natively in Apache.

For example, perhaps we would like to exclude our own IP address as well as requests for the favicon.ico from the logs.

(You will need to modify the IP address to a real one for this to work – i.e. either your machine IP address if using static IP or that of your proxy server/router if proxying Internet access from your local network.)

# Prevent entries from my host address
SetEnvIf Remote_Addr "" dontlog
# Prevent entries for the favicon.ico file
SetEnvIf Request_URI "^/favicon.ico$" dontlog
# Log what remains
CustomLog logs/web.log combined env=!dontlog

Additionally, you could additionally prevent requests for the robots.txt file from being logged as well.

# Prevent entries for robots.txt
SetEnvIf Request_URI "^/robots.txt$" dontlog

NOTE: Remember to change the log type to that which you prefer, i.e. I use the combined log format instead of common. See your httpd.conf file for your current log format type.


Category: open source Time: 2004-02-18 Views: 3

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.125 (s). 12 q(s)