Uploaded image for project: 'SLF4J'
  1. SLF4J
  2. SLF4J-389

SimpleLogger caches System.err and System.out

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 1.7.23
    • 1.7.x
    • None
    • None

    Description

      We usually use SimpleLogger in tests, and some other binding when running in production.
      In some cases, our tests depend on log values logged through the logger during a test.
      Unfortunately between version 1.7.0 and 1.7.1 this ability has been removed, since the SimpleLogger now caches the system stream in a static initialiser.
      Here is the code that broke this approach:
      https://github.com/qos-ch/slf4j/commit/996ccc7ca507994465c069554954ecb01890d4d5

      Basically, we would write a test:

      PrintStream err = System.err;
      PrintStream temp = new PrintStream(some buffer here);
      System.err = temp;
      // run tests

      System.err = err;
      // here we assert that the temp stream contains values we expect

      Unfortunately SimpleLogger now caches the system stream and never releases it, meaning swapping the streams to catch the output is not possible.

      Attachments

        Activity

          People

            ceki Ceki Gülcü
            ipolevoy Igor Polevoy
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: