在 Rails 4 中使用记录器 [英] Using logger in Rails 4
本文介绍了在 Rails 4 中使用记录器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在处理一个 Rails 4 项目,当我调用 Rails.logger.debug "test"
时,我似乎无法在我的开发日志中显示任何内容我已经尝试过在网上搜索,但我觉得我没有取得太大进展.我将如何设置记录器并告诉它写入我的开发日志文件?
I'm working on a Rails 4 project, and I can't seem to make anything show up in my development log when I call Rails.logger.debug "test"
I've tried searching online but I feel like I haven't made much progress. How would I go about setting up a logger and telling it to write in my development log file?
任何帮助将不胜感激.
推荐答案
我认为你应该在你的方法中像这样使用它.在此处查看第 2.3 节
I think you should use it like this in your method. Checkout section 2.3 here
def your_method
logger.debug "This is from debug"
logger.info "This is from info"
end
这篇关于在 Rails 4 中使用记录器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文