[英]does debug level INFO also show error too? django
我为django使用了这样的LOGGING
设置,但是我意识到使用DEBUG
级别,它表明了太多,尤其是模板variableDoesNotExist
debug
非常烦人。
我将其作为当前设置
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'simple_time': {
# simple_time, that just outputs the log level name (e.g., DEBUG) plus time and the log message.
'format': '%(levelname)s %(asctime)s %(message)s'
},
},
'handlers': {
'debug_file': {
'class': 'logging.FileHandler',
'filename': os.path.join(BASE_DIR) + '/debug.log',
'formatter': 'simple_time'
},
},
'loggers': {
'django': {
'handlers': ['debug_file'],
'level': 'DEBUG',
'propagate': True,
},
},
}
我想知道是否将level
更改为INFO
它将仅显示INFO
而不显示ERROR
级别(如果有)?
否则,是否可以将不同级别划分为不同文件?
我尝试过类似的方法,但不确定是否可以正常使用
'handlers': {
'debug_file': {
'class': 'logging.FileHandler',
'filename': os.path.join(BASE_DIR) + '/debug.log',
'formatter': 'simple_time'
},
'info_file': {
'class': 'logging.FileHandler',
'filename': os.path.join(BASE_DIR) + '/info.log',
'formatter': 'simple_time'
},
},
'loggers': {
'django_debug': {
'handlers': ['debug_file'],
'level': 'DEBUG',
'propagate': True,
},
'django_info': {
'handlers': ['info_file'],
'level': 'INFO',
'propagate': True,
},
},
在此先感谢您的任何建议
设置日志级别始终意味着要显示该级别或更高级别的任何内容。
从文档中可以看到,ERROR高于INFO,因此将级别设置为INFO会同时显示-以及最高级别的WARNING和CRITICAL。
但是,您当然可以为不同的级别设置两个不同的记录器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.