logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Coding & Scripting Corner View previous topic :: View next topic
Reply to topic   Topic: Filtering the error.log without recompiling?
Author
danbv



Joined: 28 Mar 2008
Posts: 2
Location: Boston, MA

PostPosted: Fri 28 Mar '08 16:47    Post subject: Filtering the error.log without recompiling? Reply with quote

Is there an easy way to filter messages so they do not appear in the Apache error.log file, without modifying source code and recompiling? (On Windows 2003 Server.) I want to remove some useless messages that are spamming up the logs:

1. This error from the PHP mssql package, which isn't really an error:

[Thu Mar 27 21:16:43 2008] [error] [client nn.nn.nn.nn] Query: Changed database context to 'databasename'.

2. This error about having a colon in the URL, which is perfectly legal in MediaWiki:

[Thu Mar 27 21:17:37 2008] [error] [client nn.nn.nn.nn] (20024)The given path misformatted or contained invalid characters: Cannot map GET /wiki/Special:Specialpages HTTP/1.1 to file, referer: http://wikiname/wiki/wikiarticle

I tried running the messages through a perl script:

ErrorLog "|perl c:/perl/bin/vp-apache-logger c:/apache2/logs/error2.log"

where the script looks like this:

#!c:\perl\bin\perl

#########################################################
# Quick wrapper for apache logging to eliminate log spam
#########################################################

my @bad_patterns =
(
"The given path misformatted or contained invalid characters:"
);

my $logfile = $ARGV[0];
open(FP, ">>$logfile") or die("Cannot append to $logfile");
foreach my $line (<STDIN>) {
for my $pattern (@bad_patterns) {
if ($line !~ /$pattern/) {
print FP "x $line";
}
}
}
close(FP);

but this is not great, because the log messages get buffered and don't appear quickly enough (or sometimes don't seem to appear at all).

Any suggestions for a better approach?
Thanks.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Mon 07 Apr '08 20:51    Post subject: Reply with quote

With mod_rewrite the : should work like on other pages Wink
Also you can configure your error log in httpd.conf and you can turn of error logging from php in your php.ini

If you still have a question please ask again.

Mario
Back to top
danbv



Joined: 28 Mar 2008
Posts: 2
Location: Boston, MA

PostPosted: Mon 07 Apr '08 22:09    Post subject: Reply with quote

Thanks Mario. Do you have any specific examples?

- How can mod_rewrite solve this problem? The colons are necessary for MediaWiki pages like Special:Allpages and Help:Contents.

- You say we can "configure error log in httpd.conf". That is what I tried to do in my original post. If you have another way to configure it, that would be very helpful.

- Turning off error logging in php.ini is not so good, because I want to see real PHP errors. Just not this one PHP error about databases.

Thanks!
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Mon 07 Apr '08 22:30    Post subject: Reply with quote

Please see
http://www.mediawiki.org/wiki/Manual_talk:Short_URL#MediaWiki_1.82_.htaccess_method_for_wikis_stored_in_subfolder_of_root

and

http://www.apachelounge.com/viewtopic.php?p=996
Back to top


Reply to topic   Topic: Filtering the error.log without recompiling? View previous topic :: View next topic
Post new topic   Forum Index -> Coding & Scripting Corner