puts vs logger in rails rake tasks

后端 未结 8 1531
情书的邮戳
情书的邮戳 2021-01-30 06:24

In a rake task if I use puts command then I see the output on console. However I will not see that message in log file when app is deployed on production.

However if I s

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-30 06:27

    In Rails 2.X to redirect the logger to STDOUT in models:

    ActiveRecord::Base.logger = Logger.new(STDOUT)
    

    To redirect logger in controllers:

    ActionController::Base.logger = Logger.new(STDOUT)
    

提交回复
热议问题