Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-1659

Log4j logger in TestExecutionListener corrupts Surefire's STDOUT.

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.0-M3
    • 2.22.3, 3.0.0-M6
    • None
    • None

    Description

      I have a project that registers a JUnit 5 TestExecutionListener. The TestExecutionListener contains an SLF4j Logger, using Log4j2 as the underlying library. There is a log4j2.xml on the classpath, logging to console, and Surefire is set up to redirect output.

      Running the tests gives the following result.

      [WARNING] Corrupted STDOUT by directly writing to native stream in forked JVM 1. See FAQ web page and the dump file ...

      I've attached a minimal reproduction.

      Doing either of the following eliminates the error:

      • Not having the log4j2.xml on the classpath
      • Not having the Logger in the TestExecutionListener

      Attachments

        1. surefire-stdout-corrupt.zip
          8 kB
          Stig Rohde Døssing
        2. src.zip
          6 kB
          Edinson E. Padrón Urdaneta

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            tibordigana Tibor Digana
            srdo Stig Rohde Døssing
            Votes:
            4 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment