I am building an application with Heroku and having some problems. I want to debug some content like I do with rails serve开发者_StackOverflow中文版r:
logger.debug '...'
How can I do that in Heroku, so I can see the debugging in heroku logs? (or anything else..)
Thanks!
Details here: http://devcenter.heroku.com/articles/logging
Also make sure you set the right Logging level for your Rails app: http://blog.sethladd.com/2005/11/adjust-log-level-in-ruby-on-rails.html
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'.
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.
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
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.
This worked for me:
heroku config:set LOG_LEVEL=debug
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.
config.log_level = ENV['APP_LOG_LEVEL'] ? ENV['APP_LOG_LEVEL'].to_sym : :error
精彩评论