How do I log the entire trace back of a Ruby exception using the default Rails logger?

后端 未结 7 777
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-31 08:29

I am working on rails project and I am trying to get exceptions to be logged to the rails log files. I know I can call logger.error $! to get the first line of the

7条回答
  •  旧时难觅i
    2021-01-31 08:53

    In later versions of Rails, simply uncomment the following line in RAIL_ROOT/config/initializers/backtrace_silencers.rb (or add this file itself if it's not there):

    # Rails.backtrace_cleaner.remove_silencers!
    

    This way you get the full backtrace written to the log on an exception. This works for me in v2.3.4.

提交回复
热议问题