空手道:如何将方案ID添加到日志记录配置中? [英] Karate: How can I add scenario id to the logging config?

查看:49
本文介绍了空手道:如何将方案ID添加到日志记录配置中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用此处中的日志记录配置,我们希望将方案ID添加到模式.

We are using the logging config from here and we want to add scenario id to the pattern.

我试图在文档中或互联网上找到答案,但是我没有找到有关如何将变量(某些数据)从Java传递到logback-test.xml

I was trying to find out the answer in the documentation or on the internet but I didn't find anything about how to pass a variable (some data) from Java to logback-test.xml

logback-test.xml中,我们有这样的东西:

In logback-test.xml we have something like this:

<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>

我们想要这样的东西:

<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg - %scenarioId %n</pattern>

推荐答案

我不知道有什么方法可以在log4j/logback中做到这一点.如果您找不到任何内容,我说为什么不在测试中 print 将显示在HTML报告中.

I am not aware of any way to do that in log4j / logback. If you don't find anything I say why not print it in your test and it will show up in the HTML report.

您是否真的在使用并行运行器?通常,您无需查看日志-因为即使您并行运行,您也会为每种情况获得不错的HTML报告.

Are you actually using the parallel runner ? Normally you never need to look at logs - because even if you run in parallel, you will get a nice HTML report for each scenario.

如果您看到Karate Gatling自述文件,我没有尝试过-它提到了如何将karate对象传递到JS或Java中.如果您使用

an idea I haven't tried, if you see the Karate Gatling readme - it mentions how you can pass the karate object into JS or Java. If you use the ScriptBridge type, it has a log(...) method that you may be able to call from Java - which should output to the same logger as the currently executing Scenario. You may be able to come up with some custom strategy to prefix the scenario-id etc and log from your selenium code.

这篇关于空手道:如何将方案ID添加到日志记录配置中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆