开发者

Good Way to Email Exceptions

开发者 https://www.devze.com 2023-02-08 03:33 出处:网络
I am running a site on Ubuntu with Apache and using PHP and Zend Framework. I would like exception information emailed to the devs and am wondering about a good way to do this.I don\'t want to email

I am running a site on Ubuntu with Apache and using PHP and Zend Framework.

I would like exception information emailed to the devs and am wondering about a good way to do this. I don't want to email every single exception right away because if something major happens, our inboxes will get floo开发者_如何学Cded.

Instead, I am looking for a way that the exceptions and errors from the past hour can be emailed all at once (up to a certain size limit). I am thinking about writing a cron script to parse Apache's error_log but perhaps there are easier ways than doing that.


I'd recommend Hoptoad: http://hoptoadapp.com/pages/home


I work on a open source project. It's a ticket tracker that can receive error reports from any other PHP app, can detect duplicates to avoid email floods and email developers.

Look at http://elastik.sf.net/ and the "ErrorReportingService" module.

Version 0.3.1 is coming in several days with big improvements to the error collecting mechanisms.

Sample of an error report is at http://jarofgreen.wordpress.com/2011/01/30/tracking-errors-with-php/


If you're not interested in hosted solutions, and already using the Zend Framework, it shouldn't be too hard to write the errors to a special database or log, and have a periodically run process send the aggregated information.

As an example, my dayjob has an app that does this in a most stripped-down way: We use an extremely basic log (much like the apache logs), and a periodic process gets the content of the log, emails it, and truncates the file so that no old entries will be sent next time.

Of course, depending on how robust a solution you're looking for, you may want to go another route.


I just give some links which I think should be useful.

  • error_log: write errors to log and then let cron send them using email.
  • set_exception_handler:

Sets the default exception handler if an exception is not caught within a try/catch block. Execution will stop after the exception_handler is called.

  • set_error_handler:

Sets a user function (error_handler) to handle errors in a script.

  • Exceptions in PHP - Try/Catch or set_exception_handler??
  • http://www.slideshare.net/ZendCon/elegant-ways-of-handling-php-errors-and-exceptions-presentation
0

精彩评论

暂无评论...
验证码 换一张
取 消