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

时间:2020-07-16 09:47:43

标签: python python-3.x python-logging

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

1 个答案:

答案 0 :(得分:0)

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以获得详细信息。