I am trying to get the trace and span IDs to show up in my logging. Reading https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/log4j/log4j-context-data/log4j-context-data-2.17/library-autoconfigure I followed the example and can get trace and span IDs to show up when using the PatternLayout
but when I switch to using the below it doesn’t work and just shows a string literal instead
<Console name="console" target="SYSTEM_OUT" follow="true">
<JsonTemplateLayout eventTemplateUri="classpath:EcsLayout.json">
<EventTemplateAdditionalField key="traceID" value="${ctx:trace_id}">
</JsonTemplateLayout>
</Console>
I’ve also tried $${ctx:trace_id}
, ${mdc:trace_id}
, $${mdc:trace_id}
, ${json:mdc:trace_id}
, and $${json:mdc:trace_id}
and it still doesn’t work.