LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-11-2010, 09:25 AM   #1
andrew777
LQ Newbie
 
Registered: Feb 2009
Posts: 14

Rep: Reputation: 0
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
 
Old 05-11-2010, 10:15 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,674

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by andrew777 View Post
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.
 
Old 05-13-2010, 08:56 PM   #3
andrew777
LQ Newbie
 
Registered: Feb 2009
Posts: 14

Original Poster
Rep: Reputation: 0
TB0ne, tried what you suggested but it did not work. It is still logging the images. Any other ideas? Thanks
 
Old 05-13-2010, 09:34 PM   #4
frndrfoe
Member
 
Registered: Jan 2008
Distribution: RHEL, CentOS, Ubuntu
Posts: 379

Rep: Reputation: 38
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Postfix No Longer Writes To Log carlosinfl Linux - Server 2 03-03-2010 09:38 AM
Apache .htaccess <files> and <limit> nathan2225 Linux - Software 0 10-22-2007 04:59 AM
Apache log files ikarus Linux - Server 2 04-21-2007 09:52 PM
apache program writes files in the apache group, how can I change? muskiediver Linux - Security 5 01-17-2007 12:27 PM
Question on Apache Log Files JLDixon Linux - Software 1 10-12-2003 11:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration