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 certain this module is being run
- 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.
精彩评论