具有delay_job日志"puts",SQL查询和作业状态 [英] Have delayed_job log "puts", sql queries and jobs status

查看:61
本文介绍了具有delay_job日志"puts",SQL查询和作业状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,只有以下内容记录到logs/delayed_job.log:

Right now only the following are logged to logs/delayed_job.log:

2012-04-20T03:57:44+0000: Cacher completed after 5.3676
2012-04-20T03:57:44+0000: 1 jobs processed at 0.1744 j/s, 0 failed ...

我想做的是使其也记录我所有的puts以及我的SQL查询,就像它在开发模式下一样,只是它仍然会记录到log/delayed_job.log.

What I'm trying to do is to have it also log all my puts as well as my SQL queries, like it does in development mode, except it still gets logged to log/delayed_job.log.

我尝试将以下内容添加到initializers/delayed_job_config.rb,但没有运气:

I tried to add the following to initializers/delayed_job_config.rb but no luck:

Delayed::Worker.logger = Rails.logger
Delayed::Worker.logger.level = Logger::DEBUG

(我的所有puts现在都已记录,但是没有更多的作业状态日志,仍然没有SQL查询)

(all my puts get logged now, but no more job status logs and still no SQL queries)

推荐答案

此链接可能对您有所帮助: https://stackoverflow. com/a/7223681/445908

maybe this link helpful to you: https://stackoverflow.com/a/7223681/445908

已更新:关于认沽权的更多信息. v.s记录器:

UPDATED:a bit more about puts. v.s logger:

我不确定您将"puts"结果存储到日志文件中的实现方式是什么.但是,我认为始终使用"logger"而不是"puts"可能是一个更好的选择.原因是:

I am not sure what your implementation of making "puts" result stored into log file. however I think it could be a much better choice to ALWAYS use "logger" instead of "puts". the reasons are:

  1. 在大多数情况下,puts会降低性能(尤其是在生产环境中,在我过去的所有项目中,puts都不允许出现在源代码中)(对于Java程序员,System.out.println是相同的东西)

  1. in most of the cases, puts can slow down your performance(especially in production environment, in all of my past projects, puts is not allowed to appear in the source code) ( for java programmer, System.out.println is the same stuff)

始终使用logger,因为它具有5个默认级别:调试,信息,警告,错误,致命,这些级别可以通过grep之类的工具进行控制,精美格式化和过滤.例如puts可以产生下面的日志信息吗?

always use logger, since it has 5 default levels: debug, info, warn, error, fatal, which could be control and beautifully formatted and filtered by tools such as grep. e.g. can puts produce the log info below?

07:27:48 INFO: in device_resource, options: queryem??ltres67@blur.com 
07:27:48 INFO: cloudset: ??100 

这篇关于具有delay_job日志"puts",SQL查询和作业状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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