RathanaKumar
RathanaKumar

Reputation: 375

What is the difference between ThreadContext.put() and MDC.Put()?

I just want to know the difference between threadContext.put and MDC.put because I believe that both are doing the same operation.

Upvotes: 15

Views: 12653

Answers (2)

Saurav Kumar Singh
Saurav Kumar Singh

Reputation: 1478

Log4j 2 continues with the idea of the MDC and the NDC but merges them into a single Thread Context. The Thread Context Map is the equivalent of the MDC and the Thread Context Stack is the equivalent of the NDC. Although these are frequently used for purposes other than diagnosing problems, they are still frequently referred to as the MDC and NDC in Log4j 2 since they are already well known by those acronyms.

https://logging.apache.org/log4j/2.x/manual/thread-context.html

Upvotes: 11

D.B.
D.B.

Reputation: 4713

According to the log4j2 manual:

org.apache.log4j.MDC and org.apache.log4j.NDC have been replaced by the Thread Context.

Upvotes: 6

Related Questions