0
此代碼中是否有任何內容可以解釋爲什麼我的信息消息不會進入日誌。正確格式化的警告和以上都將進入這兩個日誌文件。Python日誌記錄setLevel不記錄
初始化記錄:
logger = logging.getLogger()
f = logging.Formatter('%(asctime)s\n%(levelname)s: %(funcName)s %(message)s')
out = logging.handlers.RotatingFileHandler(filename=self.f_stdout, maxBytes=1048576, backupCount=99)
err = logging.handlers.RotatingFileHandler(filename=self.f_stderr, maxBytes=1048576, backupCount=99)
out.setLevel(logging.INFO)
err.setLevel(logging.WARNING)
err.setFormatter(f)
logger.addHandler(out)
logger.addHandler(err)
用法:
logging.info('this doesnt get logged')
logging.warning('this gets logged to stdout and stderr with respective formatting')