From 7ff2d8ca71479e3a912d27de56e347cb9314266b Mon Sep 17 00:00:00 2001 From: "alex.sung" Date: Wed, 20 Mar 2019 15:14:09 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-14869=2010.0.3=E5=9F=8B=E7=82=B9=20?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF=E6=94=B6=E9=9B=86=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=A0=86=E6=A0=88=E8=AE=B0=E5=BD=95=EF=BC=88?= =?UTF-8?q?=E8=87=B3=E5=A4=9A=E8=AE=B0=E5=BD=9515=E8=A1=8C=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/errorinfo/ErrorInfo.java | 10 ++++++++++ .../errorinfo/ErrorInfoLogAppender.java | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java b/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java index 052aaef9fe..c16b035cf4 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java @@ -25,6 +25,7 @@ public class ErrorInfo { private String templateid; private String logid; private String log; + private String stackTrace; public ErrorInfo(String username, String uuid, String activekey) { this.username = username; @@ -89,6 +90,14 @@ public class ErrorInfo { this.log = log; } + public String getStackTrace() { + return stackTrace; + } + + public void setStackTrace(String stackTrace) { + this.stackTrace = stackTrace; + } + private String dateToString(){ DateFormat df = FRContext.getDefaultValues().getDateTimeFormat(); return df.format(new Date()); @@ -107,6 +116,7 @@ public class ErrorInfo { jo.put("uploadtime", uploadtime); jo.put("logid", logid); jo.put("log", log); + jo.put("stackTrace", stackTrace); saveFileToCache(jo); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java b/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java index 8d4970a866..f0852abfbf 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java @@ -30,6 +30,7 @@ import java.io.InputStream; public class ErrorInfoLogAppender extends AppenderSkeleton { private static final int ERROR_LEN = 8; + private static final int ERROR_STACK_TRACE = 15; // 缓存下不变的, 没必要频繁取. private String username; @@ -73,10 +74,25 @@ public class ErrorInfoLogAppender extends AppenderSkeleton { errorInfo.setTemplateid(templateid); errorInfo.setLog(msg); errorInfo.setLogid(logid); + errorInfo.setStackTrace(readStackTrace(event)); errorInfo.saveAsJSON(); } } + private String readStackTrace(LoggingEvent event) { + String[] s = event.getThrowableStrRep(); + StringBuilder sb = new StringBuilder(); + if(s != null){ + int len = s.length; + for (int i = 0; i < len; i++) { + if(i < ERROR_STACK_TRACE){ + sb.append(s[i]).append("\n"); + } + } + } + return sb.toString(); + } + private String readLogID(String log) { String errorCode = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_ErrorCode_Prefix"); // 报错信息国际化不规范, 有些是中文分号, 有些是英文