LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   How to limit what apache writes to the log files (https://www.linuxquestions.org/questions/linux-server-73/how-to-limit-what-apache-writes-to-the-log-files-807154/)

andrew777 05-11-2010 09:25 AM

How to limit what apache writes to the log files
 
When apache creates entries in the log file (/var/log/httpd/www...) it includes all the pictures accessed on a web page as well as the html and other stuff.

I have a huge site with over 10 million pages and growing, and high traffic. My log file is now 2 gig and growing. 90% of the content of the log file are entries for each image downloaded per session.

Logging every little image downloaded from my site just wastes space and it is of no importance to me.

Is there any way to tell apache to omit logging images files or files of a certain type? This will reduce the size of my log file dramatically.

Thanks for your help.
Andy

TB0ne 05-11-2010 10:15 AM

Quote:

Originally Posted by andrew777 (Post 3964598)
When apache creates entries in the log file (/var/log/httpd/www...) it includes all the pictures accessed on a web page as well as the html and other stuff.

I have a huge site with over 10 million pages and growing, and high traffic. My log file is now 2 gig and growing. 90% of the content of the log file are entries for each image downloaded per session.

Logging every little image downloaded from my site just wastes space and it is of no importance to me.

Is there any way to tell apache to omit logging images files or files of a certain type? This will reduce the size of my log file dramatically.

Thanks for your help.
Andy

The "conditional logging" in Apache might be what you're after:

http://httpd.apache.org/docs/1.3/logs.html#conditional

From the docs:
Code:

# Mark requests from the loop-back interface
SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog
# Mark requests for the robots.txt file
SetEnvIf Request_URI "^/robots\.txt$" dontlog
# Log what remains
CustomLog logs/access_log common env=!dontlog

So, you could probably add something like
Code:

SetEnvIf RequestImg "^.jpg" dontlog
maybe. Never actually tried it, but have adjusted my Apache logs before.

andrew777 05-13-2010 08:56 PM

TB0ne, tried what you suggested but it did not work. It is still logging the images. Any other ideas? Thanks

frndrfoe 05-13-2010 09:34 PM

Have you tinkered with it?

perhaps
Quote:

SetEnvIf RequestImg "^.jpg" dontlog
would only "notlog" a file called .jpg and not *.jpg?

Having not looked at it maybe something like this...
Quote:

SetEnvIf Request_URI "*.jpg$" dontlog


All times are GMT -5. The time now is 08:48 AM.