logging console not work

配置 log 信息传输到控制台

参考官网:https://docs.djangoproject.com/en/2.1/topics/logging/

By default, this config only sends messages of level INFO or higher to the console (same as Django’s default logging config, except that the default only displays log records when DEBUG=True). Django does not log many such messages. With this config, however, you can also set the environment variable DJANGO_LOG_LEVEL=DEBUG to see all of Django’s debug logging which is very verbose as it includes all database queries:

默认情况下,此配置仅向控制台发送级别为 INFO 或更高级别的消息(与Django的默认日志记录配置相同,但默认情况下仅在DEBUG = True时显示日志记录)

import os

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'console': {
            'class': 'logging.StreamHandler',
        },
    },
    'loggers': {
        'django': {
            'handlers': ['console'],
            'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
        },
    },
}

个人按照官网给的 example 进行配置但是控制台没反应

暂时记录此 issue 待解决

 

posted @ 2018-12-12 09:28  Janey91  阅读(218)  评论(0编辑  收藏  举报