How to increase Heroku log drain verbosity to include all Rails app details?

China☆狼群 提交于 2019-11-29 04:25:53

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

I think the ActiveRecord logger object sends all SQL query logs with a DEBUG severity level. You may need to adjust the Rails.logger log level to get those in production too.

Since you are interested in dumping all Rails and Heroku logs to an external service, I can suggest you try the Progstr Logger free add-on. (Disclaimer, I work for Progstr). The add-on has a Ruby gem that will collect all Rails logs (everything that usually ends up in log/*). It will also set up a log drain that will fetch all system-level Heroku logs. In addition you get a cool web UI that lets you easily search for logs and some other nice features.

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