ppkarwasz commented on code in PR #2280:
URL: https://github.com/apache/logging-log4j2/pull/2280#discussion_r1486007187


##########
log4j-api/src/main/java/org/apache/logging/log4j/status/StatusConsoleListener.java:
##########
@@ -113,13 +149,33 @@ public void log(final StatusData data) {
     @Deprecated
     public void setFilters(final String... filters) {}
 
+    /**
+     * Resets the level and output stream to its initial values, and closes 
the output stream, if it is a non-system one.
+     */
     @Override
-    public void close() throws IOException {
-        // Get local copy of the `volatile` member
-        final OutputStream localStream = stream;
+    public void close() {
+        final OutputStream oldStream;
+        lock.lock();
+        try {
+            oldStream = stream;
+            stream = initialStream;
+            level = initialLevel;
+        } finally {
+            lock.unlock();
+        }
+        closeNonSystemStream(oldStream);
+    }

Review Comment:
   Instead of remembering the initial state of the listener, wouldn't it be 
easier to create a new `StatusConsoleListener` using 
`StatusLogger.Config.getInstance()` and **replace** the whole 
`StatusConsoleListener`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to