1
1

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 3 years have passed since last update.

Railsのloggerについてメモる

Posted at

たまにこんがらがるのでメモ。
間違ってたら申し訳ない。

loggerを指定する変数

  • Rails.logger (→config.loggerのやつね)
  • ActiveRecord::Base.logger

(デフォルトだと何が代入されているんだろう...?)

存在するLoggerたち

  • 標準出力するためのLogger
ActiveSupport::Logger.new(STDOUT)
  • ログファイルに書き出すLogger
ActiveSupport::Logger.new('log/development.log', 'daily') # 引数なしで初期化したら、log/*.logが指定されるっぽい??

これらにより、

  • ActiveRecordのログを標準出力に書き出す
  ActiveRecord::Base.logger = Logger.new(STDOUT)

その他

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?