I have asked this before without any luck, trying again.
this is what I have in my dj.rb initializer
Delayed::Worker.backend = :active_record Delayed::Worker.logger = Rails.logger #Delayed::Worker.logger = ActiveSupport::BufferedLogger.new("log/ ##{Rails.env}_delayed_jobs.log", Rails.logger.level) class Delayed::Job def logger Delayed::Worker.logger end end if JobsCommon::check_job_exists("PeriodicJob").blank? Delayed::Job.enqueue PeriodicJob.new(), 0, Constants::PROCESS_FREQ.from_now end #end
This is my job class
class PeriodicJob def perform this.logger.info "Periodic job writing #{Time.now}" # Rails.logger.info "Periodic job writing #{Time.now}" if JobsCommon::check_job_exists("PeriodicJob").blank? Delayed::Job.enqueue PeriodicJob.new(), 0, Constants::VOTE_PROCESS_FREQ.from_now end end end
the job fails with the error message
2010-08-09T13:29:59-0700: [Worker(delayed_job host:ubuntu pid:8941)] acquired lock on PeriodicJob 2010-08-09T13:29:59-0700: [Worker(delayed_job host:ubuntu pid:8941)] PeriodicJob failed with NameError: undefined local variable or method `logger' for #<PeriodicJob:0x7f5670e12580> - 1 failed attempts 2010-08-09T13:29:59-0700: [Worker(delayed_job host:ubuntu pid:8941)] 2 jobs processed at 8.4739 j/s, 2 failed ...
I am sure this has been done before.
Please help.