Bladeren bron

修改请求头traceId命名

tags/24080901
WendyYang 1 jaar geleden
bovenliggende
commit
c12f4f4cbf
3 gewijzigde bestanden met toevoegingen van 6 en 5 verwijderingen
  1. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/common/interceptor/LogInterceptor.java
  2. +2
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/common/util/MDCUtil.java
  3. +3
    -3
      pmapi/src/main/resources/logback-spring.xml

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/common/interceptor/LogInterceptor.java Bestand weergeven

@@ -23,7 +23,7 @@ public class LogInterceptor implements HandlerInterceptor {
@NonNull HttpServletResponse response,
@NonNull Object handler) {
String traceId = UUID.randomUUID().toString(true);
response.addHeader(MDCUtil.TRACE_ID, traceId);
response.addHeader(MDCUtil.TRACE_ID_HEADER, traceId);
MDCUtil.setTraceId(traceId);
return true;
}


+ 2
- 1
pmapi/src/main/java/com/ningdatech/pmapi/common/util/MDCUtil.java Bestand weergeven

@@ -12,7 +12,8 @@ import org.slf4j.MDC;
**/
public class MDCUtil {

public static final String TRACE_ID = "TraceId";
public static final String TRACE_ID = "traceId";
public static final String TRACE_ID_HEADER = "Trace-Id";

public static void setTraceId(String traceId) {
MDC.put(TRACE_ID, traceId);


+ 3
- 3
pmapi/src/main/resources/logback-spring.xml Bestand weergeven

@@ -19,7 +19,7 @@
</rollingPolicy>
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>[traceId:%X{TraceId}] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n
<Pattern>[traceId:%X{traceId}] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n
</Pattern>
</layout>
<charset>UTF-8</charset>
@@ -41,7 +41,7 @@
</rollingPolicy>
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>[traceId:%X{TraceId}] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n
<Pattern>[traceId:%X{traceId}] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n
</Pattern>
</layout>
<charset>UTF-8</charset>
@@ -51,7 +51,7 @@
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
[traceId:%X{TraceId}] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n
[traceId:%X{traceId}] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n
</pattern>
<charset>UTF-8</charset>
</encoder>


Laden…
Annuleren
Opslaan