質問

I have my app in production mode in my linode account and I get in one page a 500 internal server error the message:

We're sorry, but something went wrong.

However in my development environment works fine this page.

How can I debug this error?

How can I see the error origin in my production mode?

I want that rails show errors in production mode.

How can I do it?

Thank you!

役に立ちましたか?

解決

If you have access to ssh, log in to your server via ssh and go to your rails log directory, which is inside your rails directory.

Once you are there run the command tail production.log . If this doesn't give you enough information you can also do a tail -n100 production.log (gives you last hundred lines of the production log).

If you have deployed via heroku, then you can access the logs by running heroku logs in your local console. (more information here https://devcenter.heroku.com/articles/logging)

I also find it helpful to use the exception_notification gem https://github.com/rails/exception_notification when running in production, as it emails you a stacktrace when an error occurs. Plenty of others also use Hoptoad (http://hoptoadapp.com/) or Exceptional (http://www.exceptional.io/) however i prefer the simple exception_notification gem.

Also, in some rare occasions when i can't trace the error as a final measure i sometimes open up port 3000 temporarily on the remote server firewall and cd to the rails project and run rails server production with the log level set to debug in config/environments/production.rb so i can see the error in the console, and then close off the port when i have finished.

Hope that helps.

他のヒント

tail -n100 production.log

will only show the last 100 lines of the log file. Just in case you want to see the log running in real time.

use this

tail -1000f log/production.log
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top