通过电子邮件发送异常情况的好方法
我正在 Ubuntu 上使用 Apache 并使用 PHP 和 Zend Framework 运行一个网站。
我希望通过电子邮件将异常信息发送给开发人员,并且想知道有什么好方法可以做到这一点。我不想立即通过电子邮件发送每个异常情况,因为如果发生重大事件,我们的收件箱将被淹没。
相反,我正在寻找一种方法,可以一次性通过电子邮件发送过去一小时的异常和错误(最多达到一定的大小限制)。我正在考虑编写一个 cron 脚本来解析 Apache 的 error_log,但也许有比这样做更简单的方法。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我推荐 Hoptoad:http://hoptoadapp.com/pages/home
I'd recommend Hoptoad: http://hoptoadapp.com/pages/home
我从事一个开源项目。它是一个票证跟踪器,可以从任何其他 PHP 应用程序接收错误报告,可以检测重复项以避免电子邮件泛滥和电子邮件开发人员。
查看 http://elastik.sf.net/ 和“ErrorReportingService”模块。
几天后版本 0.3.1 即将发布,对错误收集机制进行了重大改进。
错误报告示例位于 http://jarofgreen.wordpress .com/2011/01/30/tracking-errors-with-php/
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/
如果您对托管解决方案不感兴趣,并且已经在使用 Zend Framework,那么将错误写入特殊数据库或日志并让定期运行的进程发送聚合信息应该不会太难。
举个例子,我的日常工作有一个应用程序,它以最精简的方式执行此操作:我们使用非常基本的日志(很像 apache 日志),并且定期进程获取日志内容,通过电子邮件发送并截断文件,以便下次不会发送旧条目。
当然,根据您正在寻找的解决方案的强大程度,您可能想要走另一条路。
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.