Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.)

like image 845
ylluminate Avatar asked Nov 06 '11 22:11

ylluminate


People also ask

How do I get all Heroku logs?

You can view logs with the Heroku CLI, the dashboard, your logging add-on, or in your log drain. You can't view logs for apps in Shield spaces with Private Space Logging enabled. Retrieve logs from your log drain instead.

What are log drains?

The Log Drains feature allows you to connect site traffic logs and function logs from Netlify's CDN to third-party monitoring services for analysis, alerting, and data persistence.

How do you delete Heroku logs?

Currently, there is no way to clear the Heroku logs. Heroku maintains a record of the past 1500 lines of log activity.


1 Answers

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
like image 115
ylluminate Avatar answered Oct 22 '22 08:10

ylluminate