I am trying to do something like the following in the log4j.xml
:
<File name="MyFile" fileName="logs/%X{client}]">
<PatternLayout>
<Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
</PatternLayout>
</File>
I have set the key as follows from the java code:
MDC.put( "client", "Roger" );
I have tried ${client}
as well inside the log4j2.xml
nothing works. How do I refer the MDC key inside the log4j2.xml
outside the layout element?
I have also specified a default value for the key under the properties section as follows:
<Properties>
<Property name="client">default</Property>
</Properties>