5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

delayed_job で backtrace を出す

Posted at

Rails のジョブキュー機能として使える、delayed_job だが、標準ではエラーが発生した際に、一番最近のエラーメッセージしか情報をつかむことができない。log でも握りつぶらされた情報しか出てこない。

対処法

config/initializers/delayed_job_config.rb に以下を追加

if Rails.env == "development"
  class Delayed::Worker
    def handle_failed_job_with_loggin(job, error)
      handle_failed_job_without_loggin(job,error)
      Delayed::Worker.logger.error(error.message)
      Delayed::Worker.logger.error(error.backtrace.join("\n"))
    end 
    alias_method_chain :handle_failed_job, :loggin
  end 
end

これで、失敗時はログに backtrace が書き出されるようになる。

参考にした資料

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?