我在pythongLOGGING
确认中得到重复的日志记录输出,以了解异常和错误。鉴于配置,这是有道理的:
LOGGING = {
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
},
'sentry': {
'level': 'WARNING',
'class': 'raven.contrib.django.handlers.SentryHandler',
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose'
},
},
'root': {
'level': 'ERROR', # Give me errors only
'handlers': ['mail_admins', 'sentry', 'console'],
},
'apps.order_shipping': {
# This module needs extra debugging, but now ERROR is duplicated
'handlers': ['console'],
'level': 'DEBUG',
},
}
我怎样才能更好地实现这一目标?我想为某些模块启用详细信息,而不会引起ERROR消息的重复。
将传播设置为False
:
{
# ...
'apps.order_shipping': {
# This module needs extra debugging, but now ERROR is duplicated
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句