【问题标题】:How to debug resque job in rails application如何在 Rails 应用程序中调试 resque 作业
【发布时间】:2012-09-12 12:00:35
【问题描述】:

如何在 rails 应用程序中调试 resque 作业?我只想在 self.perform 函数的日志文件中写一些信息。 我写了这个

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

在 self.perform() 中。但是什么也没发生。正确的方法是什么?

【问题讨论】:

    标签: ruby-on-rails ruby resque


    【解决方案1】:

    为什么不使用Logger 设施?

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

    然后tail -f 你新生成的登录"#{Rails.root}/log/resque.log'请记住重新启动您的 resque worker,因为它们会缓存代码并且不会像您的开发环境的其他部分一样接收更改!

    【讨论】:

    • 我之前也尝试过,但遇到了一些其他问题。另一种方法可以在博客文章jademind.com/blog/posts/… 中找到,它展示了如何立即登录到单独的日志文件中。
    【解决方案2】:

    Rails.logger 应该可以正常工作:

    Rails.logger.debug('foo bar')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-23
      • 2016-10-18
      • 1970-01-01
      • 1970-01-01
      • 2014-03-24
      • 2021-08-15
      相关资源
      最近更新 更多