Good Way to Email Exceptions

江枫思渺然 提交于 2021-02-19 08:23:08

问题


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 flooded.

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.


回答1:


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




回答2:


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/




回答3:


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.




回答4:


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


来源:https://stackoverflow.com/questions/4866649/good-way-to-email-exceptions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!