Error log executing scripts?
Hello, I was wondering if there is any way of making the error log in Apache to execute a script when an error is occurred, perhaps instead of writing the error directly to the log. For example, if there is a image missing Apache excutes a script that generates a replacement image? Thanx in advance Maggi [EMAIL PROTECTED]
Re: Error log executing scripts?
Magnús Þór Jónsson wrote: Hello, I was wondering if there is any way of making the error log in Apache to execute a script when an error is occurred, perhaps instead of writing the error directly to the log. For example, if there is a image missing Apache excutes a script that generates a replacement image? well, you can do just about anything you want :) however, althoughit is possible to intercept the actual errors Apache (and mod_perl) generates, it is rather complex, and really not the proper approach here. the better way is to just write your own handler to add the logic you are seeking. for instance, you could write a PerlFixupHandler that $r-filename('/some/other/file') unless -e $r-finfo; or whatnot. if you want a script to run, you could replace the $r-filename('foo') call with something like $r-set_handlers(PerlHandler = 'My::ImageGenerating::Package'); $r-handler('perl-script'); or some combination that changed $r-uri if you wanted to use a Registry script I suppose. HTH --Geoff
RE: Error log executing scripts?
-Original Message- From: Geoffrey Young [mailto:[EMAIL PROTECTED]] Magnús Þór Jónsson wrote: Hello, I was wondering if there is any way of making the error log in Apache to execute a script when an error is occurred, perhaps instead of writing the error directly to the log. For example, if there is a image missing Apache excutes a script that generates a replacement image? well, you can do just about anything you want :) however, althoughit is possible to intercept the actual errors Apache (and mod_perl) generates, it is rather complex, and really not the proper approach here. Really? I would have thought it could make an interesting caching technique - on a 404 you try and generate the file, and store in that slot in the filesystem. A cache cleanup daemon runs to clean out TTL'd files. Warning: don't try and implement this in a commercial application - it's patented by vignette. Matt. This email has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit www.star.net.uk
Re: Error log executing scripts?
however, althoughit is possible to intercept the actual errors Apache (and mod_perl) generates, it is rather complex, and really not the proper approach here. Really? I would have thought it could make an interesting caching technique - on a 404 you try and generate the file, and store in that slot in the filesystem. A cache cleanup daemon runs to clean out TTL'd files. well, I thought he meant by intercepting the actual writes to the error_log. Tatushiro actually has an interesting module on CPAN - http://cpan.valueclick.com/modules/by-module/Apache/Apache-No404Proxy-0.03.tar.gz it uses a google cache to display 404s (much to google's dismay I think :) Warning: don't try and implement this in a commercial application - it's patented by vignette. dirty-box/clean-box :) --Geoff
Re: Error log executing scripts?
Tatushiro er, Tastuhiko I mean. (sorry :) --Geoff
Re: Error log executing scripts?
On Fri, Jan 04, 2002 at 01:13:37PM -, Matt Sergeant wrote: Hello, I was wondering if there is any way of making the error log in Apache to execute a script when an error is occurred, perhaps instead of writing the error directly to the log. There is a way to redirect errors to your own code. It's not pretty. You can see some example code that does this at http://www.modperlcookbook.org/code/ch16/ You can also download an example module that uses this code to intercept error log entries and post them to an IRC channel. Nothing like real-time errors to keep you on your toes :) You can now read that entire chapter (and two others) online at http://www.modperlcookbook.org/chapters.html Enjoy! For example, if there is a image missing Apache excutes a script that generates a replacement image? In this case you're talking about a different type of error condition. As Matt and Geoff mentioned you can use an ErrorDocument script that runs whenever this condition exists. This does not handle other output that flows into your error_log. well, you can do just about anything you want :) however, althoughit is possible to intercept the actual errors Apache (and mod_perl) generates, it is rather complex, and really not the proper approach here. Really? I would have thought it could make an interesting caching technique - on a 404 you try and generate the file, and store in that slot in the filesystem. A cache cleanup daemon runs to clean out TTL'd files. Check out Apache::CacheContent - it implements something similar, available on CPAN or at http://www.modperlcookbook.org/code.html Warning: don't try and implement this in a commercial application - it's patented by vignette. Hmmm, I implemented something like this in the early 90s... Long before vignette was even around.. -- Paul Lindner[EMAIL PROTECTED] | | | | | | | | | | mod_perl Developer's Cookbook http://www.modperlcookbook.org Human Rights Declaration http://www.unhchr.ch/udhr/index.htm