aliyun / aliyun-log-logback-appender

Apache License 2.0
187 stars 64 forks source link

怎么加入自定义字段 tranceId 和appname #42

Open a1134788957 opened 2 years ago

yongorg commented 1 year ago

你解决了吗?怎么弄?

fengzidk commented 1 year ago

logback.xml 配置如下

 <appender name="xxx" class="com.aliyun.openservices.log.logback.LoghubAppender">

      <!-- 其他配置 -->
      <!-- 自定义字段 -->
        <mdcFields>traceId,appname </mdcFields>
</appender>

java 代码需要新增

MDC.put("traceId",123);
MDC.put("appname ","testApp");