0

我的日志记录设置如下:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'formatters': {
        'standard': {
            'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
            'datefmt' : "%d/%b/%Y %H:%M:%S"
        },
    },
    'handlers': {
        'null': {
            'level':'DEBUG',
            'class':'django.utils.log.NullHandler',
        },
        'logfile': {
            'level':'DEBUG',
            'class':'logging.handlers.RotatingFileHandler',
            'filename': LOG_ROOT + "/logfile",
            'maxBytes': 50000,
            'backupCount': 2,
            'formatter': 'standard',
        },
        'console':{
            'level':'INFO',
            'class':'logging.StreamHandler',
            'formatter': 'standard'
        },
    },
    'loggers': {
        'django': {
            'handlers':['console'],
            'propagate': True,
            'level':'WARN',
        },
        'django.db.backends': {
            'handlers': ['console'],
            'level': 'DEBUG',
            'propagate': False,
        },
        'home': {
            'handlers': ['console', 'logfile'],
            'level': 'DEBUG',
        },
    }
}

我这样称呼它

import logging
log = logging.getLogger('home')
log.error("Hey there it works!!")

出错No handlers could be found for logger "home"

似乎我在配置过程中遗漏了一些东西,也通过过去的SQ问题弄清楚了,但无法弄清楚。

怎么了,有什么线索吗?

提前致谢。

4

0 回答 0