我知道根记录器有lastResort
处理程序,如果根记录器处理程序没有使用logging.basicConfig
配置,并且用户使用logging.info/debug/warning/error/critical("some msg")
,则该处理程序会打印到控制台
或logger = logging.gerLogger()
后跟logger.info/debug/warning/error/critical("some msg")
但是对于使用logger = logging.getLogger("someName")
创建的子记录器,当我们编写logger.info/debug/warning/error/critical("some msg")
,并且没有配置处理程序时,当propagate = true
,那么子记录器是否有任何默认处理程序?或者它会返回到祖先的处理程序,然后返回到根记录器的处理程序,如果祖先/根记录器没有处理程序,则返回到根记录器lastResort
处理程序
如果propagate设置为false,那么是否会有一些默认的处理程序分配给子记录器
简而言之:logging.lastResort
长话短说:
根据doc,如果没有提供日志记录配置,那么:
同样根据logging source code:
因此,如果没有处理程序,它将调用} ,这是:
lastResort
,不管它是根记录器还是子记录器lastResort
实际上是^{因此您可以看到它实际上是一个具有警告级别的StreamHandler
相关问题 更多 >
编程相关推荐