Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1759

LoggerContext.reset() closes Jansi-OutputStream

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • 1.3.12, 1.5.12
    • 1.3.8
    • logback-core
    • None

    Description

      Description

      For my tests, I am reloading my Logback configuration via the following code snippet:

      loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory
      configurator = new JoranConfigurator()
      configurator.setContext(loggerContext)
      loggerContext.reset()
      configurator.doConfigure(runResourcesPath.resolve("path.xml").toFile) 

      However, a call to loggerContext.reset() will call close() on the OutputStream of a ConsoleAppender (c.f. OutputStreamAppender.closeOutputStream()). If configured with Jansi, this will be the Jansi stream which will now be closed. This will prevent any more writing being done to this stream (i.e. the Jansi stream), e.g., if we are reloading Logback to point to a different console.

      Expected Behaviour

      On loggerContext.reset(), a ConsoleAppender configured with Jansi should not close its output stream (as this is the Jansi stream). If configured without Jansi the stream can be closed without problems.

      Environment

      • Logback: 1.3.7 and 1.3.8
      • Jansi: 1.8 and 2.4.0
      • Java: 1.8 and 11
      • Windows 10

      Attachments

        Activity

          People

            ceki Ceki Gülcü
            wfr Wolfgang F. Riedl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: