登录python + mod_wsgi应用 [英] Logging in python + mod_wsgi app

查看:70
本文介绍了登录python + mod_wsgi应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在apache服务器上部署了python flask应用程序.这是我的abc.conf文件:

I've deployed a python flask app on an apache server. Here is my abc.conf file:

WSGIDaemonProcess voting_app threads=5
WSGIScriptAlias /election /var/www/voting_app/voting.wsgi

LogLevel info
ErrorLog "/var/www/voting_app/error.log"
CustomLog "/var/www/voting_app/access.log" combined

<Directory /var/www/voting_app>
    WSGIProcessGroup voting_app
    WSGIApplicationGroup %{GLOBAL}
    Order deny,allow
    Allow from all
</Directory>

要检查调试,我在应用程序中犯了语法错误.重新启动服务器时,出现500个服务器错误,但是在任何地方都看不到错误的详细信息.我检查了添加为日志的两个文件-它们完全空白. /var/log/apache2中的日志文件也是如此.我在这里想念什么?

To check debugging I made a syntax error in my application. On restarting the server, I am getting a 500 server error but I cant see the details of the error anywhere. I checked the two files I added as logs - they're completely blank. So are the log files in /var/log/apache2. What am I missing here?

推荐答案

在生产环境中运行Flask而不是使用内置的开发服务器时,它将把应用程序异常转换为HTTP 500响应,但不会记录任何内容.所以您所看到的是正常的.

When running Flask in a production setting, rather than with the built in development server, it will convert application exceptions into HTTP 500 responses but not log anything. So what you are seeing is normal.

如果您是唯一浏览该网站的人,则可以临时启用调试模式,就像使用开发服务器自动进行调试一样.有关如何执行此操作的信息,请参见:

If you are the only one viewing the site, you can enable debug mode temporarily like would be done automatically with the development server. For how to do this see:

http://flask.pocoo.org/docs/quickstart/#debug-模式

特别是:

app.debug = True

其中"app"是Flask类实例.

where 'app' is the Flask class instance.

这将导致错误的详细信息显示在发出请求的浏览器中.

This will cause details of errors to be shown in the browser making the request.

在真正的生产系统上,您显然不应该使用该软件,因此在这种情况下,您应该设置Flask来记录此类应用程序错误.为此,请参见:

On a true production system you obviously shouldn't be using that so in that case you should set up Flask to log such application errors. For that see:

http://flask.pocoo.org/docs/errorhandling/

这篇关于登录python + mod_wsgi应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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