how to change the rails logger to use standard out from rake tasks (rails2)

前端 未结 3 608
误落风尘
误落风尘 2021-02-19 07:05

When I do

Rails.logger.debug \"hello world\" from within my rake tasks I want it to log to standard out.

How do I set the rails logger to Logger.new(STDOUT) fro

相关标签:
3条回答
  • 2021-02-19 07:16

    I just did Rails.logger = Logger.new(STDOUT) and that also worked (rails3)

    0 讨论(0)
  • 2021-02-19 07:24

    With rails 4 you will be using the gem rails_12factor. Place this into your Gemfile and voilà! gem 'rails_12factor_'

    0 讨论(0)
  • 2021-02-19 07:26

    You can reset the default logger this way:

    RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
    

    You can also set the logger for specific parts of your application (ActiveRecord, ActionController...) like this:

    ActiveRecord::Base.logger = Logger.new(STDOUT)
    
    0 讨论(0)
提交回复
热议问题