On appfog, how to find the reason for 500 Internal Server Error?

守給你的承諾、 提交于 2019-12-21 06:29:21

问题


I have created a simple python flask application, which is working fine at http://cm-test.aws.af.cm/

But, when you access it on the route http://cm-test.aws.af.cm/redis it fails with "500 Internal Server Error"

The problem is, I can't find a way to see some log or error message about the problem... Is this syntax error, or exception, or something else?

How can I get more information about this error?

I can't find nothing on the dashboard and there is nothing in the logs ("af logs cm-test")


回答1:


On the command line, you can use af logs <appname> to view your application's server output/log.




回答2:


It took me so long to figure this out , Appfog doesnt provide the error logs from your application at runtime, it might show the compilation logs something like if you have done some indentation error. You have to handle the errors in your code . Initially i tried with try: except: but that also didnt create any logs. You have to add the below code in your python program

import logging
from logging import FileHandler

application = app = Flask(__name__)

file_handler = FileHandler("debug.log","a")
file_handler.setLevel(logging.WARNING)
app.logger.addHandler(file_handler)
@app.route('/')

And after that you can see the logs through af like this --

af files appname app/debug.log



回答3:


even though you should not do this in production, to troubleshoot, you can turn debugging on.

app.debug = True

This will show you the error message if on flask side instead of the 500




回答4:


I guess the logs are deleted. Same problem was with my app. I tried restarting the app and then af logs appname

The logs appeared then.



来源:https://stackoverflow.com/questions/13844376/on-appfog-how-to-find-the-reason-for-500-internal-server-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!