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")
On the command line, you can use af logs <appname>
to view your application's server output/log.
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
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
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