关于java:低代码系统改造ttl和log4j2实现全局日志跟踪

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

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理