[
https://issues.apache.org/jira/browse/LOG4J2-3315?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17469480#comment-17469480
]
Kamlesh Silag commented on LOG4J2-3315:
---------------------------------------
[~ggregory]. I found the solution to my problem, the class where i was adding
MDC.put() was base class and the inherited class logs was not able to lookup
that particular key-value pair.
Solution -
{code:java}
-Dlog4j2.isThreadContextMapInheritable=true{code}
:)
This works with both the version 2.15.0 and 2.17.1. I'm good to close this
> %X[key] is not working with bridge api ( Log4j 1.x bridge 2.15.0)
> -----------------------------------------------------------------
>
> Key: LOG4J2-3315
> URL: https://issues.apache.org/jira/browse/LOG4J2-3315
> Project: Log4j 2
> Issue Type: Question
> Components: Configuration
> Affects Versions: 2.15.0
> Reporter: Kamlesh Silag
> Priority: Minor
>
> Hi, I am trying to migrate one of the app from 1.x to 2.15.0. We were using
> MDC for lookups and as per bridge api, we can still use MDC for lookups.
> In Code, we use
>
> {code:java}
> MDC.put("PID", someFunction());{code}
>
> FYI, _MDC.get("PID)_ gives correct lookup information
> Configuration File-
>
> {code:java}
> appender.rolling.layout.type = PatternLayout
> appender.rolling.layout.pattern = %d{dd MMM yyyy HH:mm:ss,SSS} %-5p [%t]
> [%X{PID}] %c - %m%n{code}
> h2. *But, %X\{PID} is giving blank.*
>
> Dependencies we are using-
> # log4j-1.2-api-2.15.0.jar
> # log4j-api-2.15.0.jar
> # log4j-core-2.15.0.jar
> # log4j-jcl-2.15.0.jar
> # commons-logging-1.1.1.jar
>
>
>
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)