Have delayed_job log "puts", sql queries and jobs status
logging, ruby, ruby-on-rails
Solution
maybe this link helpful to you: https://stackoverflow.com/a/7223681/445908
UPDATED:a bit more about puts. v.s logger:
I am not sure what your implementation of making "puts" result stored into log file. however I think it could be a much better choice to ALWAYS use "logger" instead of "puts". the reasons are:
in most of the cases, `puts` can slow down your performance(especially in production environment, in all of my past projects, `puts` is not allowed to appear in the source code) ( for java programmer, `System.out.println` is the same stuff)
always use `logger`, since it has 5 default levels: debug, info, warn, error, fatal, which could be control and beautifully formatted and filtered by tools such as `grep`. e.g. can `puts` produce the log info below?
07:27:48 INFO: in device_resource, options: queryem??ltres67@blur.com
07:27:48 INFO: cloudset: ??100
Problem
Right now only the following are logged to `logs/delayed_job.log`: ``` 2012-04-20T03:57:44+0000: Cacher completed after 5.3676 2012-04-20T03:57:44+0000: 1 jobs processed at 0.1744 j/s, 0 failed ... ``` What I'm trying to do is to have it also log all my `puts` as well as my SQL queries, like it does in development mode, except it still gets logged to `log/delayed_job.log`. I tried to add the following to `initializers/delayed_job_config.rb` but no luck: ``` Delayed::Worker.logger = Rails.logger Delayed::Worker.logger.level = Logger::DEBUG ``` (all my `puts` get logged now, but no more job status logs and still no SQL queries)