Pergunta

I'm having some issues with the Resque logger. It all works well when i start it normally from the command line (it flushes to standard output). But as soon as I deamonize it, I don't see the log anymore. I thought it would default to the Rails app logger, but nothing shows up there. Plus, I'm using a library which writes most of its output (mostly for debugging purposes) to standard error and standard output (namely, $stderr and $stdout). Do these constants flush to the resque logger (moreover, should they)? How could I bundle them all together?

Not only that, I wanted to write the log of a forked process into a separate file, that is, I need to change the log file before I process the job. Where (which hook) is the best for it?

Foi útil?

Solução

Question-1 :

I thought it would default to the Rails app logger

Answer 1:

Nope Resque logger default log to STDOUT you have change it to log to specific file.

Question 2:

Plus, I'm using a library which writes most of its output (mostly for debugging purposes) to standard error and standard output (namely, $stderr and $stdout).

Answer 2:

Nope, unless they log there output with Resque.logger.[info|warn|error] syntax

Question 3:

Not only that, I wanted to write the log of a forked process into a separate file, that is, I need to change the log file before I process the job. Where (which hook) is the best for it?

Answer 3:

Well I think you can do that all you have to do is redefine the Resque.logger in resque hook like before_perform

   def self.before_perform
     Resque.logger = File.open(File.join("path"))
   end

and then use Resque.logger.[info | warn | error] everywhere

Hope this help

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top