玩弄日志继承,对我看到的有效日志级别有点困惑
我的文件结构如下:
project/
--> __init.py__
--> some_folder/
----> some_file.py
在__init.py__
中,我从yaml文件中的dict配置创建根记录器。我记录了它的effectiveLevel,它与预期的一样(在yaml文件中设置为INFO)。但是,我将记录器的effectiveLevel记录在某个_file.py中,结果是0。我意识到非根记录器默认为level NOTSET(0),但我希望effectiveLevel与根记录器相同,因此INFO与0相反
知道为什么吗
编辑添加的创建日志记录器的代码:
亚马尔:
version: 1
disable_existing_loggers: False
formatters:
simple:
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
handlers:
console:
class: logging.StreamHandler
level: DEBUG
formatter: simple
stream: ext://sys.stdout
root:
level: INFO
handlers: [console]
propagate: no
配置膨胀:
with open('path_to_yaml', 'r') as f:
config = yaml.load(f.read())
logging.config.dictConfig(config)
看起来我错误地假设它将继承
root
的级别。看起来我需要添加一个名为项目的记录器来完成预期的行为相关问题 更多 >
编程相关推荐