Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.