我的项目使用rails 4.2.7
和delayed_job (4.0.6)
以及delayed_job_active_record (4.0.3)
。我们面临的问题是,延迟作业每分钟左右记录一次sql查询,这使得主日志文件不那么透明,并且会占用我们的Logmatic订阅限制。延迟作业正常记录到自己的日志,但其活动记录查询最终会在主日志中结束。大多数条目看起来像这样:
(0.8ms) SELECT COUNT(*) FROM `delayed_jobs` WHERE (failed_at is not NULL)
(0.5ms) SELECT COUNT(*) FROM `delayed_jobs` WHERE (locked_by is not NULL)
(0.7ms) SELECT COUNT(*) AS count_all, `delayed_jobs`.`queue` AS delayed_jobs_queue FROM `delayed_jobs` WHERE (run_at <= '2017-02-12 23:18:18.094189' and failed_at is NULL) GROUP BY `delayed_jobs`.`queue`
(0.8ms) SELECT COUNT(*) AS count_all, `delayed_jobs`.`priority` AS delayed_jobs_priority FROM `delayed_jobs` WHERE (run_at <= '2017-02-12 23:18:18.095817' and failed_at is NULL) GROUP BY `delayed_jobs`.`priority`
之前的开发人员介绍了这里描述的delayed_job消音器: How to ignore Delayed Job query logging in development on Rails 但它似乎不起作用,因为查询仍记录在登台日志和Logmatic中。
有没有办法停止记录这些(如果它们无法完全沉默,可能会将它们重定向到另一个文件)?假设我们仍然想记录那些与delayed_job
无关的条目。
答案 0 :(得分:0)
您可以更改DJ工作人员在初始化程序中登录的日志文件,如下所示:
Delayed::Worker.logger = Logger.new(File.join(Rails.root, 'log', 'delayed_job.log'))
这应该清理主日志。
编辑:刚看到这不会影响AR日志。
您是否尝试将DJ日志级别设置为信息而不是调试?