子记录器的默认设置(日志处理程序、日志级别、日志格式)是什么



当我使用logging.getLogger(__name__)创建子记录器时,它是否有默认的日志处理程序、日志级别和日志格式?

log = logging.getLogger(__name__)
print(log.__dict__)  # this gives attributes dictionary

输出:

{'filters': [], 'name': '__main__', 'level': 0, 'parent': <RootLogger root (WARNING)>, 'propagate': True, 'handlers': [], 'disabled': False, '_cache': {}, 'manager': <logging.Manager object at 0x000001ECCF434520>}

print('value of level attribute (i.e. log level) is: ',log.__getattribute__('level'))  # this gives value of individual attributes

输出:

value of level attribute (i.e. log level) is: 0这里的日志级别0表示NOTSET

检查https://docs.python.org/3/library/logging.html详细信息。

最新更新