19
20

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.

rails のログ出力設定

Last updated at Posted at 2012-04-03

rails 3.2.2 で確認。

デフォルトのまま使用するとログに出力日時が設定されていなかったり
ローテションしてくれなかったりするので、その指定を行う。

config/environments/xxxx.rb
config.logger = Logger.new(config.paths["log"].first, 'weekly') # 週ごとにローテート
config.logger.level = Logger::WARN
config.logger.formatter = Logger::Formatter.new
config.logger.datetime_format = "%Y-%m-%d %H:%M:%S"

出力結果は以下のようなになる。

[2012-04-03 15:30:43 #13160] INFO -- : Completed 200 OK in 118ms (Views: 34.4ms | ActiveRecord: 1.5ms)

19
20
2

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
19
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?