Search code examples
log4jmavensurefire

How to show log4j output in surefire test resports


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

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.

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.

  • 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?

Solution

  • Update the surefire plugin version.

    Using version 2.9 the log4j output appears in <system-out> when using the ConsoleAppender