rambulance: Any way to suppress Rails FATAL logging when handled by rambulance?

Hi @yuki24,

Thanks for creating this gem. I’m testing it out, and it looks really nice and seems to work well.

My question is with the following example / scenario:

The following curl command: curl -D - -X PUT --data "not json" -H "Content-Type: application/json" http://localhost:3000

would generate a ActionDispatch::ParamsParser::ParseError.

When I configure rambulance like this, it works great and returns a 400 as expected.

config.rescue_responses = {
  'ActionDispatch::ParamsParser::ParseError' => :bad_request,
  ...
}

So far so good. One thing that I noticed however, even when requests are caught and handled correctly by rambulance, rails still logs a FATAL message, which gets emailed automatically on production. It’s great to get an email for something that wasn’t handled, but when it is handled by rambulance, then I wonder if there’s a way to suppress this error from being logged and prevent an email from being sent out?

(I know it’s probably not strictly an issue with rambulance, but I would appreciate your help / thoughts about this)

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 15 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I found a solution to keep my lograge logs clean… If you configure it to keep the original rails logs, then the unformatted messages go there instead.

config.lograge.keep_original_rails_log = true
config.lograge.logger = ActiveSupport::Logger.new "#{Rails.root}/log/lograge_#{Rails.env}.log"
config.lograge.enabled = true

With this setup the fatal message (not formatted)

NameError (undefined local variable or method `asdfds' for #<WelcomeController:0x007fcbe5c27b68>):
  app/controllers/welcome_controller.rb:3:in `index'

goes into the rails log and lograge log includes only the well formatted message

2015-06-10T08:42:13-07:00 app="rails_loaded"|method="GET"|path="/"|format="html"|controller="WelcomeController"|action="index"|status="500"|duration="3.57"|view="0.0"|db="0.0"|error="NameError: undefined local variable or method `zsd' for #<WelcomeController:0x007fecf95dfc80>"

I’m sort of happy. lol