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
  • Generally speaking it is appreciated if you actually post what you have tried that didn't work.
    – Jenny D
    May 22, 2013 at 7:11

1 Answer 1


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...


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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