如何增加Heroku日志冗余度以包含所有Rails应用程序的详细信息? [英] How to increase Heroku log drain verbosity to include all Rails app details?

查看:118
本文介绍了如何增加Heroku日志冗余度以包含所有Rails应用程序的详细信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在Heroku Celadon Cedar上运行一个Rails 3.1.x应用程序,而且它似乎很少有日志详细程度。我已经将日志级别设置为DEBUG a la heroku config:add LOG_LEVEL = DEBUG --app app_name ,这符合他们的建议,但除此之外,我似乎无法拉在日志/ *文件内容中。

从Thin改为Unicorn的确略微增加了冗长度,但仅限于web worker请求。我仍然无法拉下数据库请求等等。

通过herokudrain机制最大化日志详细程度的最佳方法是什么,以便人们可以将所有实例日志合并为一个内聚日志?



(理想情况下,我想包含一个方法将其转储到我自己的日志服务器中,因为这只是一个痛苦,不能轻易看到特定的事件和周围的情况。)

解决方案

在staging.rb,production.rb或任何您正在运行的环境中,您可以插入以下内容:

  STDOUT.sync = true 

logger = Logger.new(STDOUT )
logger.level = 0#此处必须为数字 - 0:debug,1:info,2:warn,3:错误,4:致命
#注意:0代表您将要获取所有数据库调用等

Rails.logger = Rails.application.config.logger = logger

###注意:一定要注释掉这些:
#查看日志中的所有内容(默认为:info)
#config.log_level =:debug#根据Heroku的Chris指令注释

#使用另一个记录器分发设置
#config.logger = SyslogLogger.new


Presently I'm running a Rails 3.1.x app atop Heroku Celadon Cedar and it seems that log verbosity is very much lacking. I have set the log level to DEBUG a la heroku config:add LOG_LEVEL=DEBUG --app app_name, which matched up to their recommendation, however beyond that I cannot seem to pull in the log/* file contents.

Changing from Thin to Unicorn did increase verbosity slightly, but only in web worker requests. I still cannot pull down the db requests and so forth.

What is the best way to maximize log verbosity via the heroku "drain" mechanism so that one can pull all instance logs into one cohesive log?

(Ideally I'd like to include a method to dump this into one of my own log servers as this is just a pain the rear not being able to readily look at specific events and surrounding conditions in time.)

解决方案

In staging.rb, production.rb or whatever environment you're running, you can insert the following:

STDOUT.sync = true

logger = Logger.new(STDOUT)
logger.level = 0 # Must be numeric here - 0 :debug, 1 :info, 2 :warn, 3 :error, and 4 :fatal
# NOTE:   with 0 you're going to get all DB calls, etc.

Rails.logger = Rails.application.config.logger = logger

### NOTE: Be sure to comment out these:
#   See everything in the log (default is :info)
#   config.log_level = :debug  # Commented out as per Chris' instructions from Heroku

#   Use a different logger for distributed setups
#   config.logger = SyslogLogger.new

这篇关于如何增加Heroku日志冗余度以包含所有Rails应用程序的详细信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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