GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Apache Error Conditional logs -tech help please. (https://gfy.com/showthread.php?t=963976)

camperjohn64 04-17-2010 09:20 AM

Apache Error Conditional logs -tech help please.
 
Does anyone have experience with the conditional logs of apache?

I have 10x to 20,000 404 errors every day (which are actually correct, and are redirected to affiliate programs), and dont want to log those:
[Sat Apr 17 21:15:25 2010] [error] [client 195.42.102.25] File does not exist: /home/photof/public_html/cats/random.htlm

Is there a way I can get apache to log all errors except those?
http://httpd.apache.org/docs/2.2/logs.html

What environment variable do you think I could use to regex against to acheive this goal?

LoveSandra 04-17-2010 10:20 AM

bump bump

Varius 04-17-2010 01:56 PM

ErrorLog doesn't support Env conditions, so you'll probably have to use CustomLog and pipe it to a sed command or script to strip out the unwanted lines.

camperjohn64 04-17-2010 02:28 PM

Oh yes I see it is possible to pipe it. Good idea.

I will try this:
ErrorLog "|/usr/bin/php /home/john/test.php"

and see if I can make a little php program that checks for the 404 condition and doesn't write it if so

Or do you think it would run faster if it was written as a shell script?

I don't know I would write a shell script that would "If string not contain "404" and string not contain "not found" then write to /var/log/httpd/error_log"

camperjohn64 04-17-2010 02:50 PM

So far, I don't think I can do this in PHP. I think this is an excersize for another day. But I did find this:

http://www.sudleyplace.com/pipederrorlogs.html

Varius 04-17-2010 03:11 PM

I'm not home right now so didn't test this but just try something simple like:

ErrorLog "|/bin/grep -v 'File does not exist:' >> /var/log/httpd/error_log"

Should do the trick.

camperjohn64 04-17-2010 10:26 PM

Hmmm.. I think this is a syntax issue, but it's close

Code:

Starting httpd: grep: does: No such file or directory
grep: not: No such file or directory
grep: exist:: No such file or directory
                                                          [FAILED]


camperjohn64 04-17-2010 10:26 PM

I really think I need to do it in a shell script and figure out how to do it with stdin, just don't know how to yet.

rowan 04-18-2010 06:12 AM

Quote:

Originally Posted by camperjohn64 (Post 17042689)
I really think I need to do it in a shell script and figure out how to do it with stdin, just don't know how to yet.

$fp = fopen("php://stdin", "r");
if (!$fp) die("could not open STDIN");

Running a PHP script is pretty clunky, I'd try fixing what Varius gave you. Something like this shoudl work...

ErrorLog "|/bin/grep -v \"File does not exist:\" >> /var/log/httpd/error_log"

camperjohn64 04-18-2010 08:30 AM

Wow that works (with single quotes rather than double quotes):

ErrorLog "|/bin/grep -v \'File does not exist:\' >> /var/log/httpd/error_log"

Now, how do I test for two error conditions with grep?

not found or unable to stat
File does not exist:

I tried this and let's see if it works:

ErrorLog "|/bin/grep -v \'File does not exist:\' |/bin/grep -v \'not found or unable to stat\' >> /var/log/httpd/error_log"


All times are GMT -7. The time now is 02:22 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123