Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1316

LoggerContextRule doesn't work with @Rule when multiple tests log.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Invalid
    • Affects Version/s: 2.5
    • Fix Version/s: None
    • Component/s: Core
    • Labels:

      Description

      The LoggerContextRule when used with JUnit @Rule annotation to provide isolation between tests only logs the first test successfully. Subsequent tests do not log at all.

      The issue appears to be with the call to `Configurator.shutdown(context);`. It seems to prevent future calls to `Configurator.initialize(...` from working properly. I have not seen any indication that repeated cycles of calls to `Configurator.initialize` and `Configurator.shutdown` should not create working contexts.

      As a test, I removed Configurator.shutdown and this resulted in the expected behavior. I assume that is not a legitimate fix seeing that it would leak active contexts.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              justinrknowles@gmail.com Justin Knowles
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: