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


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

  2.  install plugin
    ruby script/plugin install git://github.com/rails/exception_notification.git -r '2-3-stable'
  3.  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
  4. 如何想能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
    

  5. rails2如何配置发送邮件?

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

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





  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值