首页 > 解决方案 > 日志未填充在 PyCharm(pytest 框架)中生成的 HTML 报告中

问题描述

我已生成 HTML 报告,但在日志文件中捕获的日志未显示在 HTML 报告中。它始终显示为未捕获日志。

下面是我使用的代码:

import logging


class LogGen:
   @staticmethod
   def loggen():
       for handler in logging.root.handlers[:]:
           logging.root.removeHandler(handler)
       logging.basicConfig(filename="./Logs/automation.log",
                           format='%(asctime)s: %(levelname)s: %(message)s', 
                           datefmt='%m/%d/%Y %I:%M:%S %p')
       logger = logging.getLogger()
       logger.setLevel(logging.INFO)
       return logger

这是结果的图像。

图片

标签: htmlfileloggingpycharmreport

解决方案


推荐阅读