Resque 的日志记录问题 [英] Logging issues with Resque

查看:38
本文介绍了Resque 的日志记录问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将 Resque 添加到我的 Rails 3 项目中.我创建了一个从/向数据库读取/写入一些内容的作业.

I have added Resque to my Rails 3 project. I have created a job which reads/writes some stuff from/to the DB.

问题是我在终端中看不到 SQL 查询日志,例如 "Post Load (0.5ms) SELECT "posts".* FROM "posts"".我也没有看到我设置的任何 Rails.logger 消息.

The problem is I do not see the SQL query logs such as "Post Load (0.5ms) SELECT "posts".* FROM "posts"" in the terminal anymore. I am also not seeing any Rails.logger messages I have set up.

当我再次发出请求(简单刷新)时,记录器消息和 SQL 查询日志突然显示.

When I make yet another request (simple refresh) the logger messages and SQL query logs suddenly show up.

任何想法可能会发生什么?谢谢

Any ideas what could be going on? Thanks

推荐答案

Rails 不会立即写入日志文件,它会在刷新文件之前等待一定数量的行经过.您可以通过将其添加到您的 development.rbapplication.rb 文件中来告诉 Rails 始终刷新日志...

Rails won't write out to the log file immediately, it waits for a certain amount of lines to go by before flushing the file. You can tell Rails to always flush the log by adding this to your development.rb or application.rb file...

config.logger.auto_flushing = true

只在开发中这样做,永远不要在生产中设置它,因为它只会杀死你的 I/O.

Only ever do this in development, and never set this in production as it will just kill your I/O.

您也可以根据需要...

You can also do it on demand with...

Rails.logger.flush

API 文档在这里...

API documentation here...

http://api.rubyonrails.org/classes/ActiveSupport/BufferedLogger.html#method-i-auto_flushing-3D

这篇关于Resque 的日志记录问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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