# 解决日志重复打印的问题 log_logger.handlers.clear()

This commit is contained in:
Valuebai 2021-05-14 09:46:05 +08:00 committed by GitHub
parent bae751df23
commit 202e7a4901
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -248,6 +248,8 @@ class GetLogger:
"""在logger中添加日志句柄并返回如果logger已有句柄则直接返回""" """在logger中添加日志句柄并返回如果logger已有句柄则直接返回"""
# 实例化root日志对象 # 实例化root日志对象
log_logger = logging.getLogger('root') log_logger = logging.getLogger('root')
# 解决日志重复打印的问题
log_logger.handlers.clear()
# 设置日志的输出级别 # 设置日志的输出级别
log_logger.setLevel(self.logs_level) log_logger.setLevel(self.logs_level)