Skip to content

Logging markers with StructuredArguments #483

Answered by philsttr
viartemev asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @viartemev ,

To print structured arguments when using a pattern layout, include an argument substitution string ({}) for each structured argument in the message format string (just like non-structured arguments). For example...

logger.info("log message {} {}",
    StructuredArguments.keyValue("key1", "value1"),
    StructuredArguments.keyValue("key2", "value2"));

... results in a log event with the message log message key1=value1 key2=value2

StructuredArguments will not be printed when using logback's %markers conversion word.

Note that StructuredArguments and the markers provided by logstash-logback-encoder are primarily designed for use with the encoders provided by logstash-logback-…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by philsttr
Comment options

You must be logged in to vote
0 replies
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
Converted from issue

This discussion was converted from issue #452 on January 17, 2021 20:04.