出于某种原因,在我试图修改的Python应用程序中,记录器没有记录任何内容。我跟踪误差logging/__init__.py
禁用Python默认记录器
def handle(self, record):
"""
Call the handlers for the specified record.
This method is used for unpickled records received from a socket, as
well as those created locally. Logger-level filtering is applied.
"""
if (not self.disabled) and self.filter(record):
self.callHandlers(record)
我不知道为什么,但self.disabled
是True
。在应用程序中没有任何地方设置这个值,我不认为任何包都在改变它。记录器像往常一样实例化logger = logging.getLogger(__name__)
。当我在设置logger.disabled = False
之前(在调用logger.info()
之前)记录任何内容时,记录器将打印预期的日志文本。但是,如果我不这样做,它将返回handle()
而不记录任何内容。
有什么办法可以调试吗?或许可以改变Logger
类,所以,每当disabled
被写入一些功能被称为...
真棒 - 作品像魅力。感谢堆! (1) – orange 2015-02-24 12:06:55