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 98d4942bcebd31b0a0a8352b9ed3375a013d06d3..b706b29e56302858cd1a57bdb23c2bc74c9c34d5 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){