My project uses rails 4.2.7
with delayed_job (4.0.6)
and delayed_job_active_record (4.0.3)
. The problem we're facing is that Delayed Job logs its sql queries every minute or so, which makes main log files less transparent and eats up our Logmatic subscription limits. Delayed Job logs to its own log normally, but its activerecord queries end up in the main log. Most of the entries look like this:
(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`
The previous developer introduced this delayed_job silencer described here: How to ignore Delayed Job query logging in development on Rails but it doesn't seem to work, since the queries are still logged in staging logs and in Logmatic.
Is there a way to stop logging these (perhaps redirect them to another file if they can't be silenced completely)? Assume we still want to log such entries that are not delayed_job
-related.
You can change the logfile in which the DJ worker log in a initializer like this:
Delayed::Worker.logger = Logger.new(File.join(Rails.root, 'log', 'delayed_job.log'))
This should clean your main log.
Edit: Just seen that this will not affect the AR logs.
Have you tried setting the DJ log level to info instead of debug?