Skip to content

🌳 Log4j2 TTL ThreadContextMap, Log4j2 extension integrated TransmittableThreadLocal to MDC

License

Notifications You must be signed in to change notification settings

oldratlee/log4j2-ttl-thread-context-map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌳 Log4j2 TTL ThreadContextMap

Github Workflow Build Status Coverage Status JDK support License Maven Central GitHub release GitHub Stars GitHub Forks user repos GitHub repo size gitpod: Ready to Code



πŸ”§ Functions

πŸ‘‰ Enable the transmitting Log4j2 ThreadContext(ThreadLocal value) between threads even using thread pooling components by Transmittable ThreadLocal(TTL).

From v1.4+ upgrade to Java 8.
If you need Java 6 support, use version 1.3.x Maven Central

πŸ‘₯ Usage

Just add this dependency into your project to activate the Log4j2 TTL ThreadContextMap. ✨

πŸƒ Run Demo

Run Demo Code

./mvnw clean test-compile -Dexec.classpathScope=test -Dexec.mainClass=com.alibaba.ttl.log4j2.Log4j2Demo exec:java

./mvnw clean test-compile -Dexec.classpathScope=test -Dexec.mainClass=com.alibaba.ttl.log4j2.Slf4jMdcDemo exec:java

πŸͺ Dependency

<!--
    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.4.0</version>
    <scope>runtime</scope>
</dependency>

Find up-to-date available versions at search.maven.org.

πŸ“š Related resources