AdamGold
AdamGold

Reputation: 5051

Heroku debugging

I am building an application with Heroku and having some problems. I want to debug some content like I do with rails server:

logger.debug '...'

How can I do that in Heroku, so I can see the debugging in heroku logs? (or anything else..)

Thanks!

Upvotes: 32

Views: 25896

Answers (7)

Omer
Omer

Reputation: 21

config.log_level = ENV['APP_LOG_LEVEL'] ? ENV['APP_LOG_LEVEL'].to_sym : :error

Upvotes: 0

Steven Soroka
Steven Soroka

Reputation: 19902

This worked for me:

heroku config:set LOG_LEVEL=debug

Upvotes: 6

Jerry Clinesmith
Jerry Clinesmith

Reputation: 424

Using Rails 3.2, we made this configurable by modifying config/environments/{environment}.rb to drive it from an environment variable:

config.log_level = ENV["LOG_LEVEL"].to_sym if ENV["LOG_LEVEL"]

Then, we can modify the Heroku config variable to change it:

heroku config:set LOG_LEVEL=debug --app <app name>

This lets us easily log more or less as needed.

Upvotes: 6

user664833
user664833

Reputation: 19505

To write to your logs on Heroku, instead of using logger.debug "..." simply use puts:

puts "..."

You don't even need to set the config.log_level setting in config/environments/production.rb.

See the docs here.

Upvotes: 1

Michael Schmitz
Michael Schmitz

Reputation: 1084

Been fighting with this for a long time, solution is nice and simple:

Set in production.rb instead of

config.log_level = :debug

place:

config.logger = Logger.new(STDOUT)
config.logger.level = Logger::DEBUG

and you get the full logging output.

Upvotes: 12

Blockpusher
Blockpusher

Reputation: 306

The Cedar stack in Heroku does not appear to be responsive to the LOG_LEVEL config (env) variable that works for previous stacks (I use the logging:expanded addon). I tried setting LOG_LEVEL to both debug and DEBUG without success.

Only by setting config.log_level = :debug in config/environments/production.rb am I able to see the output of 'logger.debug'.

Upvotes: 12

Douglas F Shearer
Douglas F Shearer

Reputation: 26488

heroku logs on your command line will give you the logs for the current app. If you have expanded logging turned on you can tail this output

Upvotes: 9

Related Questions