在Rails 4中使用记录器 [英] Using logger in Rails 4

查看:79
本文介绍了在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?

任何帮助将不胜感激.

Any help would be greatly appreciated.

推荐答案

我认为您应该在方法中像这样使用它.在第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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆