共计 529 个字符,预计需要花费 2 分钟才能阅读完成。
ttl
ttl 源码
log4j2-PatternLayout
PatternLayout
实现
jvm 增加启动参数:
-javaagent:path/to/transmittable-thread-local-2.x.y.jar
援用 maven:
<!--
because this dependency is implemented by log4j2 runtime extension
that will never be used by biz code,
set scope to *runtime*.
-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>log4j2-ttl-thread-context-map</artifactId>
<version>1.3.3</version>
<scope>runtime</scope>
</dependency>
log4j2 xml 配置:[%X{traceId}]
log4j2 新增 properties 配置文件 log4j2.component.properties,内容:
log4j2.threadContextMap=com.alibaba.ttl.log4j2.TtlThreadContextMap
正文完