How to debug resque job in rails application

qmaruf picture qmaruf · Sep 20, 2012 · Viewed 7.3k times · Source

How can I debug a resque job in rails application? I just want to write some info in a log file from self.perform function. I have written this

system("echo sos >> /home/maruf/Desktop/log.txt")

in self.perform(). But nothing happened. What is the proper way?

Answer

pdu picture pdu · Sep 20, 2012

Why not use the Logger facility?

log = Logger.new 'log/resque.log'
log.debug "foo bar"

And then tail -f your newly generated log in "#{Rails.root}/log/resque.log'. Remember to restart your resque workers as they cache the code and won't pick up changes like the rest of your development environment!