哪个Django / Python处理程序类会将日志传递给UWSGI记录器?

时间:2017-10-14 16:52:29

标签: django python-3.x logging uwsgi

我正在运行我的Django网站作为UWSGI皇帝的附庸。我创建了/etc/uwsgi-emperor/vassals/mysite.ini如下:

[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?

1 个答案:

答案 0 :(得分:3)

您可以使用logging.StreamHandler课程。例如,在settings.py中定义LOGGING,如下所示:

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