Docker运行rake任务时在Rails4中记录问题 [英] Log issue in Rails4 with Docker running rake task

查看:111
本文介绍了Docker运行rake任务时在Rails4中记录问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的rails4应用程序正在使用docker运行.它运行一个rake任务,用于从AWS SQS提取消息.

My rails4 application is running with docker. It runs a rake task for fetching messages from AWS SQS.

我遇到的问题是日志无法及时显示在控制台中.在出现异常/错误之前,控制台不会显示任何内容.换句话说,如果我的应用程序运行正常,则不会有任何日志进入控制台.但是,如果应用程序出错,则所有日志(信息,警告和错误)都将汇总在一起!

The problem I met is that logs can't show up in a console in time. The console doesn't show anything until exception/error comes. In other words, if my application works fine, no logs come to console. But if application went wrong, all the logs(info, warn and error) come together!

我已经将 config/production.rb 配置为打击:

config.logger = Logger.new(STDOUT)
config.logger.level = Logger.const_get('INFO')
config.log_level = :info

我在Google上搜索耙任务日志无法正常工作",但没有任何用处.这是Rails日志问题还是rake任务日志问题,还是docker问题?

I google 'rake task log was not working', but nothing useful. Is this a rails log problem or a rake task log problem, or maybe a docker problem?

希望得到一些建议!

推荐答案

尝试禁用对STDOUT的输出缓冲.您可以通过在耙任务中添加以下行来完成此操作:

Try disabling output buffering to STDOUT. You can do this by adding this line to your rake task:

$stdout.sync = true

这篇关于Docker运行rake任务时在Rails4中记录问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆