Reputation: 768
I'm trying to debug a Heroku app. I'm having trouble with local Rails, so I'm using Heroku to debug. I'm getting an HTTP 500 response from some of my POST requests, and the only thing Heroku is willing to tell me is:
$ heroku logs
... lots of other stuff ...
POST app.heroku.com/games dyno=web.1 queue=0 wait=0ms service=36ms status=500 bytes=0
How can I get more information than this about my server error?
Upvotes: 1
Views: 656
Reputation: 907
You can catch server errors in Rails and log them. The simplest way to do that is to add a rescue_from
clause in your controller. That will let you define a method to be invoked when an uncaught exception bubbles up from your code.
rescue_from UserNotFoundError, :with => :user_not_found
def throw
#Triggers a UserNotFound error
@user = User.find(42)
end
def user_not_found(exception)
Rails.logger.warn { "User not found\n#{exception.backtrace.join("\n\t")}" }
@message = "Exception logged."
render :errors
end
For bonus points, you can add that to your base ApplicationController
class.
I am working on Progstr Logger, a free Heroku add-on that makes storing and searching through logs easier. We also have an online example that does a similar thing to catch errors.
Upvotes: 0
Reputation: 21784
Are you aware of Heroku logging? In your local application directory:
$ heroku logs
You could also try expanded logging
$ heroku addons:upgrade logging:expanded
$ heroku logs --tail
Upvotes: 2