我将尝试对我的 Selenium 框架进行简要描述,以便我可以解释我的问题。
I use 硒2(当前版本2.3.1)+测试NG 5.14
我设置 testng.xml 文件来并行运行测试套件中的测试,只有 2 个实例
出于记录目的,我使用logback(我读过这是日志世界中下一个最好的事情)
我的问题是,当检查应用程序日志内容时,我得到如下信息:
18:48:58.551 [TestNG] 信息 d.a.a.s.t.setup.TestConfiguration -
从用户池中检索随机用户
18:48:58.551 [TestNG] 信息 d.a.a.s.t.setup.TestConfiguration -
从用户池中检索随机用户
18:48:58.551 [TestNG] 调试 d.a.a.s.t.setup.TestConfiguration -
创建数据源以访问数据库
18:48:58.551 [TestNG] 调试 d.a.a.s.t.setup.TestConfiguration -
创建数据源以访问数据库
18:48:58.552 [TestNG] 调试 d.a.a.s.t.setup.TestConfiguration -
启动 SQL 查询
18:48:58.552 [TestNG] 调试 d.a.a.s.t.setup.TestConfiguration -
启动 SQL 查询
18:48:59.613 [TestNG] TRACE d.a.a.s.t.setup.TestConfiguration - 查询
成功的
18:48:59.613 [TestNG] TRACE d.a.a.s.t.setup.TestConfiguration - 查询
成功的
正如您所看到的,不可能看出同时运行的两个线程之间的差异。我的问题是,有没有办法可以配置 logback 设置,以便它们还添加一个数字或 Id 来标识每个正在运行的线程?
PD 以防万一它可能有帮助,我的日志记录文件文件看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/selenium.log</file>
<encoder>
<pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="trace">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
</configuration>