Oliverwqcwrw commented on code in PR #4590:
URL: https://github.com/apache/rocketmq/pull/4590#discussion_r923078906


##########
logging/src/main/java/org/apache/rocketmq/logging/inner/LoggingBuilder.java:
##########
@@ -708,17 +708,30 @@ public synchronized void setFile(String fileName, boolean 
append, boolean buffer
                     throw ex;
                 }
             }
-            Writer fw = createWriter(ostream);
-            if (bufferedIO) {
-                fw = new BufferedWriter(fw, bufferSize);
+            Writer fw = null;
+            try {
+                fw = createWriter(ostream);
+                if (bufferedIO) {
+                    fw = new BufferedWriter(fw, bufferSize);
+                }
+                this.setQWForFiles(fw);
+                this.fileName = fileName;
+                this.fileAppend = append;
+                this.bufferedIO = bufferedIO;
+                this.bufferSize = bufferSize;
+                writeHeader();
+                SysLogger.debug("setFile ended");
+            } catch (Exception e) {
+                throw e;
+            } finally {
+                if (ostream != null) {
+                    ostream.close();
+                }
+                if (fw != null) {

Review Comment:
   Thank you very much for your advice
   
   I tried it and did get an error when printing logs asynchronously, so I 
turned off pr for now



-- 
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