You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ta...@apache.org on 2019/08/22 03:14:56 UTC
[skywalking] branch master updated: Log message cached unexpected
(#3303)
This is an automated email from the ASF dual-hosted git repository.
tanjian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new b051f6b Log message cached unexpected (#3303)
b051f6b is described below
commit b051f6b09407c912568498f2f1561b420594e219
Author: 吴晟 Wu Sheng <wu...@foxmail.com>
AuthorDate: Thu Aug 22 11:14:51 2019 +0800
Log message cached unexpected (#3303)
---
.../apm/agent/core/logging/core/FileWriter.java | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/core/FileWriter.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/core/FileWriter.java
index 1b0c6ef..279df37 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/core/FileWriter.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/logging/core/FileWriter.java
@@ -65,14 +65,18 @@ public class FileWriter implements IWriter {
.newSingleThreadScheduledExecutor(new DefaultNamedThreadFactory("LogFileWriter"))
.scheduleAtFixedRate(new RunnableWithExceptionProtection(new Runnable() {
@Override public void run() {
- logBuffer.drainTo(outputLogs);
- for (String log : outputLogs) {
- writeToFile(log + Constants.LINE_SEPARATOR);
- }
try {
- fileOutputStream.flush();
- } catch (IOException e) {
- e.printStackTrace();
+ logBuffer.drainTo(outputLogs);
+ for (String log : outputLogs) {
+ writeToFile(log + Constants.LINE_SEPARATOR);
+ }
+ try {
+ fileOutputStream.flush();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ } finally {
+ outputLogs.clear();
}
}
}, new RunnableWithExceptionProtection.CallbackWhenException() {
@@ -165,8 +169,7 @@ public class FileWriter implements IWriter {
}
/**
- * Write log to the queue.
- * W/ performance trade off, set 2ms timeout for the log OP.
+ * Write log to the queue. W/ performance trade off, set 2ms timeout for the log OP.
*
* @param message to log
*/