繁体   English   中英

调试级别INFO也会显示错误吗? 詹戈

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM