我已经成功地使用了exception_notification gem对于许多不同的应用程序,它在我的工作流程等方面运行良好。我喜欢报告、获取电子邮件的便利等。gem 已经 8 年没有更新了(!),但仍然运行良好,但有一个异常(exception) - 它每出现 500 个错误就会使内存膨胀。也许这只是我对应用程序的实现,但我很确定我已经按照规范完成了它(在这种情况下这将是另一个问题)。
我用 google 搜索过,但找不到另一个可以做同样事情的 gem:当我的应用程序因 500 错误而崩溃时,给我发送一封电子邮件。 exception_notification gem 有哪些替代方案?
最佳答案
这个 gem 已经有一个 fork 版本 Exception notification 。解释说:
The Exception Notification gem provides a set of notifiers for sending notifications when errors occur in a Rack/Rails application. The built-in notifiers can deliver notifications by email, Campfire, HipChat, Slack, Mattermost, IRC or via custom WebHooks.
所以这是一个更增强的版本,可以与多个第 3 方应用程序一起使用。 github中提到的链接清楚地解释了开始使用这个gem的步骤:Read me for Exception Notification
邮件选项和代码几乎相同:
Rails.application.config.middleware.use ExceptionNotification::Rack,
:email => {
:email_prefix => "[PREFIX] ",
:sender_address => %{"notifier" <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5836372c313e313d2a183d20393528343d763b3735" rel="noreferrer noopener nofollow">[email protected]</a>>},
:exception_recipients => %w{<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="11746972746165787e7f62517469707c617d743f727e7c" rel="noreferrer noopener nofollow">[email protected]</a>},
:delivery_method => :smtp,
:smtp_settings => {
:user_name => "bob",
:password => "password",
}
}
关于ruby-on-rails - Rails 中已弃用的 exception_notification gem 的替代方案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48147519/