From 790f49a43ea23ae1381e15954b84220995667ab3 Mon Sep 17 00:00:00 2001 From: wxz Date: Fri, 11 Dec 2020 10:23:57 +0800 Subject: [PATCH] =?UTF-8?q?BaseLogAspect=E4=BF=AE=E6=94=B9RenException?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF=E7=A0=81=E5=88=A4=E6=96=AD=EF=BC=8C?= =?UTF-8?q?=E5=A6=82=E6=9E=9C=E6=98=AF>8000=E8=BF=94=E5=9B=9E=E7=BB=99?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=9A=84=EF=BC=8C=E5=B0=B1=E6=89=93=E5=8D=B0?= =?UTF-8?q?warn=E7=BA=A7=E5=88=AB=E6=97=A5=E5=BF=97=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E6=8A=A5=E8=AD=A6=E7=BB=99=E9=92=89=E9=92=89=E3=80=82?= =?UTF-8?q?=E5=A6=82=E6=9E=9C<=3D8000=E5=88=99=E4=BE=9D=E6=97=A7=E6=89=93?= =?UTF-8?q?=E5=8D=B0error=E6=97=A5=E5=BF=97=EF=BC=8C=E6=8A=A5=E8=AD=A6?= =?UTF-8?q?=E7=BB=99=E9=92=89=E9=92=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/aspect/BaseRequestLogAspect.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java index 8dd819e4b7..ff877a04be 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java @@ -66,7 +66,12 @@ public abstract class BaseRequestLogAspect { resultInfoLog(transactionSerial, getExecPeriod(startTime), result); } catch (RenException e) { result = handleRenException(e); - resultErrorLog(transactionSerial, getExecPeriod(startTime), result, e.getInternalMsg(), ExceptionUtils.getErrorStackTrace(e)); + if (e.getCode() > 8000) { + resultWarnLog(transactionSerial, getExecPeriod(startTime), result, e.getInternalMsg(), ExceptionUtils.getErrorStackTrace(e)); + } else { + resultErrorLog(transactionSerial, getExecPeriod(startTime), result, e.getInternalMsg(), ExceptionUtils.getErrorStackTrace(e)); + } + return result; } catch (ValidateException e) { result = handleValidateException(e); resultErrorLog(transactionSerial, getExecPeriod(startTime), result, e.getMsg(), ExceptionUtils.getErrorStackTrace(e)); @@ -95,7 +100,7 @@ public abstract class BaseRequestLogAspect { } /** - * 异常信息 + * 异常错误级别日志 * @param transactionSerial * @param execTimeMillis * @param result @@ -107,6 +112,19 @@ public abstract class BaseRequestLogAspect { transactionSerial, execTimeMillis, result == null ? result : result.toString(), exceptionMsg, exceptionDetail); } + /** + * 异常警告级别日志 + * @param transactionSerial + * @param execTimeMillis + * @param result + * @param exceptionMsg + * @param exceptionDetail + */ + private void resultWarnLog(String transactionSerial, Long execTimeMillis, Object result, String exceptionMsg, String exceptionDetail) { + log.warn("<<<<<<<<异常响应<<<<<<<<:事务流水号:{}, 执行时长:{}ms, 响应数据:{}, 异常信息:{}, 堆栈信息:{}", + transactionSerial, execTimeMillis, result == null ? result : result.toString(), exceptionMsg, exceptionDetail); + } + /** * 计算执行周期 * @param startTime