django print information on production server

寵の児 提交于 2019-11-29 14:43:42

问题


I have some prints on my application for debug purpose. On the production server where these printed information goes? on apache log? I am using apache/mod_wsgi .

Thanks.


回答1:


use logging

I like to log to file at times so I use the following in my settings.py

import logging


logging.basicConfig(
    level = logging.INFO,
    format = '%(asctime)s %(levelname)s %(message)s',
    filename = '/tmp/djangoLog.log',)

and where I want logging:

import logging

logging.info("Making the alpha-ldap connection");

then in /tmp/djangoLog.log I would see the line "Making the alpha-ldap connection"e




回答2:


Check this thread for some pointers: In Django, how do I allow print statements to work with Apache WSGI?

That said, you shouldn't use print statements for debugging on your production system, especially as django comes with a nice, flexible logging module included nowadays.



来源:https://stackoverflow.com/questions/5653566/django-print-information-on-production-server

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