views:

14

answers:

1

When there is no database connectivity to the application, I catch the ActiveRecord::RecordNotFound exception in the rescue_action_in_public method and try to render the page which doesn't have any database access.

When this happens, I dont want the Mysql:Error exception to be logged, because for the whole period of DB down, this exception will be logged for each page access.

How can certain exceptions be prevented from being logged?

+1  A: 

Try adding this in your application_controller.rb:

EXCLUDED_EXCEPTIONS = ['ActiveRecord::RecordNotFound']

protected
def log_error(ex)
  super unless EXCLUDED_EXCEPTIONS.include?(ex.class.name)
end

You can add additional exceptions to that array to exclude them as well.

Matt