Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log full stacktrace in rails including all gems

Currently when I look in the log files of my rails application I get stacktraces like:

NoMethodError (undefined method `[]' for nil:NilClass):
  app/controllers/concerns/example.rb:192:in `rescue in create_example'
  app/controllers/concerns/example.rb:163:in `create_example'
  app/controllers/concerns/example.rb:11:in `example'
  app/controllers/example_controller.rb:39:in `create'

The error is triggered from a second project which is included as gem. On line 192 in the example.rb (concern) we use some classes from that included gem and in that class the real exception occurs.

Another example:

ZeroDivisionError (divided by 0):
  app/controllers/dummy_controller.rb:15:in `index'

And on line 15

test_object.divide_by_zero

test_object is an instance of a class defined in the included gem

I want rails to display and log the full stacktrace including all or specific gems but I can't figure out how to do this. Does someone know how to do this? or someone that can give me a push in the right direction?

Thanks!!!

like image 925
Sander Visser Avatar asked Feb 27 '15 15:02

Sander Visser


2 Answers

It's used like this:

Rails.backtrace_cleaner.remove_silencers!
like image 73
Markus Andreas Avatar answered Sep 24 '22 01:09

Markus Andreas


Depending on what version of rails you are using this may help:

http://api.rubyonrails.org/classes/ActiveSupport/BacktraceCleaner.html#method-i-remove_silencers-21

like image 26
jmccure Avatar answered Sep 26 '22 01:09

jmccure