Logging in delayed_job? Logging in delayed_job? ruby ruby

Logging in delayed_job?


When I needed log output from Delayed Jobs, I found this question to be fairly helpful.

In config/initializers/delayed_job.rb I add the line:

Delayed::Worker.logger = Logger.new(File.join(Rails.root, 'log', 'dj.log'))

Then, in my job, I output to this log with:

Delayed::Worker.logger.info("Log Entry")

This results in the file log/dj.log being written to. This works in development, staging, and production environments.