The plugin has helped me discover and fix a whole bunch of obscure errors that I never would have discovered on my own or through users complaining.
This may not be appropriate for a server where you have a large volume of users. You probably wouldn't want to get thousands of emails of the exact same error a day especially if it's a bug that you already know about. But it works great for servers with a low volume of users, or for internal test servers. For a test server, your testers won't need to record the details of the error and send it to you separately, it will automatically be sent to you!
To get started, run
script/plugin install exception_notification
Then edit your config/environment.rb file to include the following line, specifying the email addresses to send exceptions to:
ExceptionNotifier.exception_recipients = %w(email_recipient_1@address.com email_recipient_2@address.com)
Another useful option you can add to environment.rb specifies who the sender of the exception should appear as:
ExceptionNotifier.sender_address = "\"App Error\" <apperror@domain.com>"
Then add this to your application controller if you want all actions in your application to generate exception emails.
class ApplicationController < ActionController::Base include ExceptionNotifiable
You can also include this only on the controllers that you want to generate exception emails.
The full source for this is at http://dev.rubyonrails.org/browser/plugins/exception_notification. Read the README file there for more detailed information on configuring it.
No comments:
Post a Comment