Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to reduce the size of my Apache access log and needs to exclude static files from logging like js|css|xml|png|gif & more.

I am parsing access log to track user activity & website data.

I have tried DonNotLog apache directive but didn't work, may be some configuration issue with my code:(

My Apache configurations were --

SetEnvIf Request_URI "(jpg|css)" DontLog

LogFormat "%v:%p %h %l %u \"%{%s}t\" %D \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" %{username}n %{sessionID}n" vhost_combined DontLog
share|improve this question
Generally speaking it is appreciated if you actually post what you have tried that didn't work. – Jenny D May 22 '13 at 7:11
up vote 1 down vote accepted

You can do this with a combination of SetEnvIf and logging directives. Example:

SetEnvIf Request_URI "\.gif$|\.jpg$" is_static

sets all URIs ending in .gif or .jpg to have the environment variable "is_static".

CustomLog logs/access_log common env=!is_static

means that everything that does not have the is_static environment variable will be written to access_log in the common format.

Extending the regexp in the SetEnvIf directive to cover all file types you want is left as an exercise for the reader...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.