From 46fb4d67aef62882e380e4f7c8b1af0c03ea37a1 Mon Sep 17 00:00:00 2001 From: xxsgo Date: Mon, 19 Jun 2023 01:22:47 +0000 Subject: [PATCH] =?UTF-8?q?update=20tlog-core/src/main/java/com/yomahub/tl?= =?UTF-8?q?og/core/aop/AspectLogAop.java.=20=E7=8E=AF=E7=BB=95=E7=BB=93?= =?UTF-8?q?=E6=9D=9F=E6=B8=85=E9=99=A4=E4=B8=9A=E5=8A=A1=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xxsgo --- .../java/com/yomahub/tlog/core/aop/AspectLogAop.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tlog-core/src/main/java/com/yomahub/tlog/core/aop/AspectLogAop.java b/tlog-core/src/main/java/com/yomahub/tlog/core/aop/AspectLogAop.java index 98d4942..b706b29 100644 --- a/tlog-core/src/main/java/com/yomahub/tlog/core/aop/AspectLogAop.java +++ b/tlog-core/src/main/java/com/yomahub/tlog/core/aop/AspectLogAop.java @@ -97,18 +97,22 @@ public class AspectLogAop { } String aspLogValue = sb.toString(); + //拿到之前的标签 + String currentLabel = AspectLogContext.getLogValue(); if (StringUtils.isNotBlank(aspLogValue)) { aspLogValue = aspLogValue.substring(0, aspLogValue.length() - joint.length()); aspLogValue = StrUtil.format(pattern, aspLogValue); - //拿到之前的标签 - String currentLabel = AspectLogContext.getLogValue(); - MDC.put(TLogConstants.MDC_KEY, currentLabel + " " + aspLogValue); AspectLogContext.putLogValue(currentLabel + " " + aspLogValue); } - return jp.proceed(); + try{ + return jp.proceed(); + }finally { + MDC.put(TLogConstants.MDC_KEY, currentLabel); + AspectLogContext.putLogValue(currentLabel); + } } private String getExpressionValue(String expression, Map map){ -- Gitee