问题描述
Citrus Framework文档指示可以通过SLF4J日志记录系统记录集成测试控制台的输出.它是自动的还是需要以某种方式启用尚不清楚.我的经验表明,由于未生成包含测试运行控制台上显示的日志文件的日志文件,因此未启用.
The Citrus Framework documentation indicates that integration test console output can be logged via the SLF4J logging system. It's not obvious whether this is automatic, or whether it needs to be enabled in some way. My experience indicates that it's not enabled as no log file containing what appears on the test run console has been produced.
我的应用程序使用Log4J和关联的log4j2-spring.xml
文件(在src/main/resources
中)定义日志格式和文件.通过Citrus运行集成测试时,应用程序控制台输出(和其他信息)将正确记录到Log4J配置文件中指定的文件中.但是,没有在任何地方(控制台上除外)记录Citrus控制台输出.
My application uses Log4J with an associated log4j2-spring.xml
file (in src/main/resources
) to define log formats and files. When an integration test is run via Citrus, the application console output (and other information) is properly logged to the files specified in the Log4J config file. There is however, no Citrus console output logged anywhere (except on the console).
如何启用Citrus测试控制台输出的日志记录?我创建了一个单独的log4j.xml
并放置在src/test/resources
中,但这似乎已被忽略.
How do I enable the logging of the Citrus test console output? I created a separate log4j.xml
that I placed in src/test/resources
, but this seems to have been ignored.
我需要在特定于Citrus输出的配置中指定一个单独的记录器吗?
Do I need to specify a separate logger in the config that's specific for Citrus output?
推荐答案
Citrus使用SLF4J,它是那里其他几个日志记录框架的基础.因此,您需要选择自己喜欢的日志记录框架(在您的情况下为Log4J),并为该日志记录框架添加SLF4J记录器绑定.这全部在 SLF4J用户手册
Citrus uses SLF4J which is a facade to several other logging frameworks out there. So you need to pick your favorite logging framework (in your case Log4J) and add a SLF4J logger binding for that logging framework. This is all described in the SLF4J user manual
我建议将Log4J的SLF4J记录器绑定添加为项目中的测试作用域依赖项.另外,根据您的Log4J配置设置,您可能需要为com.consol.citrus
添加Log4J记录器配置,并为其设置适当的日志记录级别,以查看Log4J记录的Citrus输出.
I would suggest to add the SLF4J logger binding for Log4J as a test scoped dependency in your project. Also depending on your Log4J configuration setup you may need to add a Log4J logger configuration for com.consol.citrus
and set a proper logging level for that in order to see the Citrus output logged by Log4J.
这篇关于Citrus Framework日志记录-如何启用/使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!