Skip to content

Does this library allow for structured MDC data? #64

Answered by rfoltyns
namero999 asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, it does. Have a look at JacksonJsonLayout documentation.

MDC values are resolved with Log4j2 lookups (actually StrSubstitutor under the hood). VirtualProperty - optional and configurable within JacksonJsonLayout component - wraps StrSubstitutor and supports variable resolution just like Log4j2 KeyPair. It's quite limited though:

  • ${ctx:variableName} can be used only with synchronous loggers
  • log event properties e.g. ${event:Marker} are not supported

If you'd like to resolve MDC values, try this:

<JacksonJsonLayout>
    <VirtualProperty name="myMdcField" value="$${ctx:propertyName:-undefined}"/>
</JacksonJsonLayout>

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@namero999
Comment options

@namero999
Comment options

@rfoltyns
Comment options

@namero999
Comment options

@rfoltyns
Comment options

Answer selected by namero999
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants