log doesn't work in production with delayed job

依然范特西╮ 提交于 2019-11-30 10:30:36

Woody Peterson found the problem here: http://groups.google.com/group/delayed_job/browse_thread/thread/f7d0534bb6c7c83f/37b4e8ed7bfaba42

The problem is:

DJ is using Rails' buffered log in production, and flushing the buffer is not being triggered for some reason (don't know if it's flushed by buffer size or explicitly flushed after a request).

The temporary fix (credit to Nathan Phelps) is:

When in production the buffered log is set to an auto_flushing value of 1000 which means that flush is not called until 1000 messages have been logged. Assuming you're using collectiveidea's fork of delayed_job, you can address this by setting auto_flushing to a more reasonable value in command.rb right after the logger is initialized on line 64. I.E.

Delayed::Worker.logger = Rails.logger

Delayed::Worker.logger.auto_flushing = 1 # or whatever

Works for me perfectly!

It looks like you're trying to log to a closed file. Have you perhaps considered trying the SyslogLogger gem?

Here's an article on how to use it with rails, which should help get you started.

I've had a similar issue. The logging in the collectiveidea fork is being rewritten - see this issue for more info. Perhaps try the newest version to see if that fixes it for you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!