我想通了,谢谢Paco为我指出了正确的方向
事实证明,在
getLogger被调用时,将向其添加处理程序:
>>> print(effectivehandlers(logger))[<logging.StreamHandler object at 0x305ad90>, <logging.FileHandler object at 0x305ae10>]>>> logging.getLogger(name) #the same logger<logging.Logger object at 0x7fa08fb9b2d0>>>> print(effectivehandlers(logger))[<logging.StreamHandler object at 0x305ad90>, <logging.FileHandler object at 0x305ae10>, <logging.StreamHandler object at 0x305ad90>, <logging.FileHandler object at 0x305ae10>]
现在,孩子和父母都有相同的处理程序。因此重复输出。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)