开发者

logger.debug not writing to log file in Rails

开发者 https://www.devze.com 2023-02-22 02:39 出处:网络
I am trying to debug a model in Rails so I\'m using this code: logger.debug(\'asasd\') However, I\'m tailing the log file development.log but I\'m not seeing it add to this file.

I am trying to debug a model in Rails so I'm using this code: logger.debug('asasd')

However, I'm tailing the log file development.log but I'm not seeing it add to this file.

  1. I am certain this module is being run
  2. I have confirmed that runtime errors开发者_如何学C are logging to this file, and I see them when I tail.

How do I get this to work?


Make sure that you have set the log level to debug in environments/appropriate_env_file.rb:

config.log_level = :debug

and also make sure you are tailing the correct log file based on the environment you are running against.


You could attempt to call flush on the logger to force it to write to this file. Usually this would happen after every request:

logger.debug("asasd")
logger.flush

There's also the auto_flushing setting on the Rails.logger instance itself:

Rails.logger.auto_flushing = true

This will make the call to logger.flush unnecessary, as Rails will automatically flush the buffered output to the log file whenever it is written to.

0

精彩评论

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