开发者

Rails: Reason log config shows difference between console and logfile?

开发者 https://www.devze.com 2023-03-21 06:10 出处:网络
I have a Rails 3 app. Using the defau开发者_Go百科lt logging config, when I issue a command like logger.warn \"some message\"

I have a Rails 3 app. Using the defau开发者_Go百科lt logging config, when I issue a command like

logger.warn "some message"

Logger message appears in console and in logs.

Now I add one line to production.rb

config.logger = Logger.new(Rails.root.join("log","biteme.log"))

Logger message does not appear in console, only the logs. Then I change it to this:

config.logger = Logger.new(config.paths.log.first)

And now message appears in console and in logs. There is some knowledge here that I am missing, because it does not make sense why the first config omits log message going to console. Any ideas?


Rails actually now uses ActiveSupport::BufferedLogger instead of ruby's standard Logger class.

Try making your custom logger of that class and see if it works:

config.logger = ActiveSupport::BufferedLogger.new(Rails.root.join("log","biteme.log"))


Finally got down to the root of the problem. I was using a jasonp gem that conflicted with the logs in Heroku. Locally, no problem (of course) but running from Heroku, the log messages did not appear. When I removed that gem - log messages appear on Heroku. Am a happy camper now.

0

精彩评论

暂无评论...
验证码 换一张
取 消