哪个Django/Python处理程序类会将日志传递给UWSGI记录器? [英] Which Django/Python handler class will pass logs to the UWSGI logger?

查看:212
本文介绍了哪个Django/Python处理程序类会将日志传递给UWSGI记录器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Django网站作为UWSGI皇帝的附庸.我已经创建了/etc/uwsgi-emperor/vassals/mysite.ini,如下所示:

I am running my Django site as a vassal of UWSGI emperor. I have created /etc/uwsgi-emperor/vassals/mysite.ini as follows:

[uwsgi]
socket = /var/opt/mysite/uwsgi.sock
chmod-socket = 775
chdir = /opt/mysite
master = true
virtualenv = /opt/mysite_virtualenv
env = DJANGO_SETTINGS_MODULE=mysite.settings
module = mysite.wsgi:application
uid = www-data
gid = www-data
processes = 1
threads = 1
plugins = python3,logfile
logger = file:/var/log/uwsgi/app/mysite.log
vacuum = true

但是Django日志未出现在file:/var/log/uwsgi/app/mysite.log中. 哪个处理程序类会将日志传递到UWSGI?

But Django logs are not appearing in file:/var/log/uwsgi/app/mysite.log. Which handler class will pass the logs on to UWSGI?

推荐答案

您可以使用logging.StreamHandler类.例如,在settings.py中定义LOGGING如下:

You can use the logging.StreamHandler class. For example, defining LOGGING in settings.py as follows:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'console': {
            'level': 'DEBUG',
            'filters': None,
            'class': 'logging.StreamHandler',
        },
    },
    'loggers': {
        'django': {
            'handlers': ['console'],
            'level': 'DEBUG',
        },
    },
}

这篇关于哪个Django/Python处理程序类会将日志传递给UWSGI记录器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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