We use SLF4J (with log4j) as our logging framework. We are trying to leverage the MDC feature which as per online documentation is supported by Log4j.
MDC does not work when SLF4J is used. However, when log4j is used instead, it works perfectly fine. The documentation states that as long as the underlying framework supports MDC, SLF4J should support it.
We are using SLF4J 1.6.4 (slf4j-api
, slf4j-log4j12
have been added as dependencies in our pom.xml
).
Is there a discrepancy/mismatch somewhere? Are we missing any dependencies? Any inputs would be appreciated.
According to SLF4J's MDC javadoc, the class uses NOPMDCAdapter, an empty implementation, for slf4j-simple :
https://www.slf4j.org/api/org/slf4j/MDC.html
For NOPMDCAdapter documentation: https://www.slf4j.org/api/org/slf4j/helpers/NOPMDCAdapter.html