在appfog上,如何查找500 Internal Server Error的原因? [英] On appfog, how to find the reason for 500 Internal Server Error?

查看:101
本文介绍了在appfog上,如何查找500 Internal Server Error的原因?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个简单的python flask应用程序,该应用程序在 http://cm-test上运行良好.aws.af.cm/

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

但是,当您在路径 http://cm-test.aws.af上访问它时.cm/redis 失败,并显示"500 Internal Server Error"

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?

我无法在仪表板上找到任何内容,并且日志中也没有任何内容("af logs cm-test")

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

推荐答案

我花了很长时间才弄清楚这一点,Appfog不会在运行时提供来自应用程序的错误日志,它可能会显示编译日志,例如做一些缩进错误. 您必须处理代码中的错误. 最初,我尝试使用try:except:但它也没有创建任何日志. 您必须在python程序中添加以下代码

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('/')

然后,您可以通过af看到这样的日志-

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

af files appname app/debug.log

这篇关于在appfog上,如何查找500 Internal Server Error的原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆