1
0

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.

Lograge に設定した Logger を呼び出す方法

Last updated at Posted at 2019-07-03

概要

  • lograge を使っていても Rails.logger を直接呼び出してログを出力すると lograde 側のログに出力されない.
  • begin ~ rescueでキャッチしたエラーも lograge に出力させたかった.

方法

以下のように Rails.application.config から直接呼び出せばいいことに気づいた.

  • Rails.application.config.lograge.logger.debug({ message: '何か文字列' }.to_json)

当たり前なのだろうけど, 気づくのに時間がかかったので備忘録として残しておく. ラッパークラスを作って出力されるログの構造を統一すれば使い勝手がさらに良くなる気がする.

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?