您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

运行logging.basicConfig之前的Python日志记录?

运行logging.basicConfig之前的Python日志记录?

您可以删除认处理程序并重新配置日志记录,如下所示:

# if someone tried to log something before basicConfig is called, Python creates a default handler that
# goes to the console and will ignore further basicConfig calls. Remove the handler if there is one.
root = logging.getLogger()
if root.handlers:
    for handler in root.handlers:
        root.removeHandler(handler)
logging.basicConfig(format='%(asctime)s %(message)s',level=logging.DEBUG)
python 2022/1/1 18:38:53 有261人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶