Skip to content

Commit

Permalink
Merge pull request #389 from lostsnow/fix/recursive-log
Browse files Browse the repository at this point in the history
fixes recursive log
  • Loading branch information
lostsnow authored Oct 8, 2022
2 parents f8dce7c + c5e027c commit 5700983
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dongtai-log/src/main/java/io/dongtai/log/DongTaiLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,21 +257,21 @@ private static void writeLogToFile(String msg, Throwable t) {
return;
}
FileOutputStream o = null;
File file = new File(filePath + File.separator + "dongtai_javaagent.log");
try {
if (t != null) {
StringWriter stringWriter = new StringWriter();
t.printStackTrace(new PrintWriter(stringWriter));
msg = msg + stringWriter;
}

File file = new File(filePath + "/dongtai_javaagent.log");
o = new FileOutputStream(file, true);
o.write(msg.getBytes());
o.write(System.getProperty("line.separator").getBytes());
o.flush();
o.close();
} catch (Exception e) {
DongTaiLog.error(e);
System.out.println("the log file " + file.getPath() + " is not writable: " + e.toString());
}
}
}

0 comments on commit 5700983

Please sign in to comment.