如何在surefire测试报告中显示log4j输出 [英] How to show log4j output in surefire test resports
问题描述
当Maven中的测试失败时,target/surefire-reports/TEST-<test-name>.xml
中的surefire测试报告xml文件仅显示标准输出System.output
或标准错误System.err
When a test fails in maven the surefire test report xml files in target/surefire-reports/TEST-<test-name>.xml
only shows the Standard Output System.output
or Standard Error System.err
当我使用jdk java.util.logging.Logger
时,所有日志记录都显示在标准错误<system-err> tag
中,但是当我使用log4j时却不显示.
When I use the jdk java.util.logging.Logger
all the logging shows in the Standard Error <system-err> tag
, but it does not show when I use log4j.
使用Log4j进行日志记录可以通过FileAppender和ConsoleAppender正常工作.它显示在完整的控制台输出中,而不显示在各个测试报告文件中.
The logging with log4j is working fine through a FileAppender and a ConsoleAppender. It shows in the full console output, but not on the individual test report files.
- 是否可以将log4j配置为将其输出重定向到
System.out
,以便在surefire报表中显示? - 我可以告诉surefire还显示log4j调试日志记录吗?
- Can I configure log4j to redirect its output to
System.out
so it shows in surefire rerports? - Can I tell surefire to also show the log4j debug logging?
推荐答案
更新surefire插件版本.
Update the surefire plugin version.
使用2.9版时,使用ConsoleAppender时log4j输出出现在<system-out>
中
Using version 2.9 the log4j output appears in <system-out>
when using the ConsoleAppender
这篇关于如何在surefire测试报告中显示log4j输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!