Reduce access_log noise

This is just a quick guide to eliminate certain activity from your access_log files.

Create a new file called filter.conf (where you put this depends on your apache deployment). Adapt the patterns as necessary. See apache docs for all the possible variables. You can pile up as many filters as you like.

SetEnvIFNoCase User-Agent "Googlebot" exclude_from_log
SetEnvIfNoCase Request_URI "\.(gif)|(jpg)|(png)|(css)|(ico)$" exclude_from_log
SetEnvIfNoCase Request_Method "(OPTIONS)|(PROPFIND)" exclude_from_log

This file should be included (probably at the global level) for easiest use. For OS provided apache, either put it in /etc/httpd/conf.d or explicitly include it into httpd.conf.

Anywhere you want the filter applied, simple alter you access_log definition to include the parameter after “combined”.

CustomLog "logs/access_log" combined env=!exclude_from_log

Restart apache to pick up the change and review your access_log to make sure it worked.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s