I am using log4j-api-2.0-beta4.jar along with sl4j in my web-app. I am trying to insert some values into ThreadContext.
ThreadContext.put("user",userName); ThreadContext.put("thread",thread);
ThreadContext.put("url",url);
All I have done to get ThreadContext is to import the class.
At the end of the class, I am doing the following:
ThreadContext.clear();
The pattern layout that I am using in my log4j2.xml is:
<RollingFile name="Default" fileName="${logDir}/${filePrefix}.log"
filePattern="${logDir}/${filePrefix}/${filePrefix}.log.gz">
<PatternLayout pattern="%d %-5p [%t] %37c %X{user} %x %m%n"/>
<Policies>`enter code here`
<SizeBasedTriggeringPolicy size="10MB"/>
</Policies>
</RollingFile>
I am not getting any value as part of %X{user} and %x gives me []. I need to get these values in my log file. Please help!!!