您的位置:首页 > 大数据 > 人工智能

rails开发利器:时刻监控我们的程序错误rails exception_notification

2011-11-20 14:38 429 查看
介绍

exception_notification

rails 2.3.8 https://github.com/smartinez87/exception_notification/tree/2-3-stable

rails 3 https://github.com/rails/exception_notification

install plugin

ruby script/plugin install git://github.com/rails/exception_notification.git -r '2-3-stable'
configuration

将如下代码加入到environment.rb的最后

ExceptionNotification::Notifier.exception_recipients = %w(hexudong08@gmail.com) #接受错误的邮件
ExceptionNotification::Notifier.sender_address = %("Application Error" <yunshiteam@rayclear.com>) #发送错误的邮件
|ExceptionNotification::Notifier.email_prefix = "[APP]" #定义发送错误的级别,默认是ERROR
2.3 update application_controller.rb

include ExceptionNotification::Notifiable

如何想能development环境下测试,需要增加如下代码至application_controller.rb
def local_request?
   false
  end
并修改config/environments/development.rb
config.action_controller.consider_all_requests_local = false
config.action_mailer.raise_delivery_errors = true


rails2如何配置发送邮件?

资料

https://github.com/rails/exception_notification/tree/2-3-stable

rails3中的配置

新增gem

gem 'exception_notification', :require => 'exception_notifier'


config/application.rb文件

config.middleware.use ExceptionNotifier,
      :email_prefix => "[APP] ",
      :sender_address => %{"异常通知" <xxxxx@xxxxxx.com>},
      :exception_recipients => %w{xxxxx@163.com}


更多具体的使用
https://github.com/smartinez87/exception_notification http://www.taobaotest.com/blogs/qa?bid=13030 http://stackoverflow.com/questions/3524127/exception-notification-gem-and-rails-3 http://www.stormconsultancy.co.uk/blog/development/basic-exception-notification-in-rails-3/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: