LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 02-14-2010, 07:17 PM   #1
fukawi2
Member
 
Registered: Oct 2006
Location: Melbourne, Australia
Distribution: ArchLinux, ArchServer, Fedora, CentOS
Posts: 448

Rep: Reputation: 34
Apache Don't Log 404 Errors


I have a MediaWiki installation, which returns a 404 error to the client when they request a page that doesn't exist yet. This is correct/desired behaviour, however it is also expected behaviour, so I don't want to log these errors to the log file. Examples of these logs are:

Code:
/index.php/ArchServer_Wiki:Current_events: 2 Time(s)
/index.php/ArchServer_Wiki:General_disclaimer: 1 Time(s)
These "false positives" make it difficult to find genuine 404 errors that need attention when reviewing the logs.

I can use SetEnvIf to create a rule like:
Code:
SetEnvIf Request_URI "^/index\.php/.*$" dontlog
CustomLog "/var/log/httpd/wiki-access_log" combined env=!dontlog
But this will prevent ALL logging, which then screws up my statistics for pages that do exist. I can't see anyway to test the HTTP Status Code using SetEnvIf.
 
Old 02-15-2010, 03:42 AM   #2
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu
Posts: 1,441

Rep: Reputation: 103Reputation: 103
http://helicontech.blogspot.com/2009...abilities.html


Per status code differentiation
We all like HTTP status 200. It means 'OK' and that's why we're not interested in loging it. Most common situation is when we are looking for some psecific status code in the logs. With mod_log_config you may create separate logs for every needed status. Please look at this configuration:

CustomLog ok.log "%200t %200a,%200{User-Agent}i %200U%200q %200s"
CustomLog redirections.log "%301t %301a,%301{User-Agent}i %301U%301q %301s"
CustomLog not_found.log "%404t %404a,%404{User-Agent}i %404U%404q %404s"
CustomLog server_error.log "%500t %500a,%500{User-Agent}i %500U%500q %500s"

Hope this helps...
 
Old 02-15-2010, 03:51 AM   #3
fukawi2
Member
 
Registered: Oct 2006
Location: Melbourne, Australia
Distribution: ArchLinux, ArchServer, Fedora, CentOS
Posts: 448

Original Poster
Rep: Reputation: 34
Hmmm, a custom setenvif module... That could be a solution. Thanks, I hadn't seen that in my Googling
 
Old 02-17-2010, 01:04 AM   #4
fukawi2
Member
 
Registered: Oct 2006
Location: Melbourne, Australia
Distribution: ArchLinux, ArchServer, Fedora, CentOS
Posts: 448

Original Poster
Rep: Reputation: 34
OK, well that software from a mod_rewrite clone for IIS, so that was a no go.... But I have found a solution!

Code:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/index\.php/(.+)
RewriteCond %{REQUEST_URI} -U
RewriteRule ^(.*)$ - [env=dontlog:true]
CustomLog "/var/log/httpd/access_log" combined env=!dontlog
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
locolhost errors to a gif file and not a Html 404 error almost000 Linux - Software 5 06-02-2007 03:22 PM
why is apache giving me a 404 error linuxmandrake Linux - Software 4 06-17-2005 10:16 AM
odd Apache 404 error Seventh Linux - Software 1 03-27-2005 04:43 AM
trailing slash in Apache gives 404 errors rabbate Linux - General 6 04-30-2004 09:34 AM
More Apache Log Errors! Crashed_Again Linux - General 2 02-27-2003 06:21 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration