Citrus Framework logging - how to enable/use

六眼飞鱼酱① 提交于 2020-03-25 23:51:21

问题


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.

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).

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.

Do I need to specify a separate logger in the config that's specific for Citrus output?


回答1:


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

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.



来源:https://stackoverflow.com/questions/60153773/citrus-framework-logging-how-to-enable-use

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!