[Logback Configuration XML] How to get StructuredArgument in Json Pattern
See original GitHub issueI have following configuration:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="jsonConsoleAppender" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<providers>
<pattern>
<pattern>
{
"SESSION_ID": "%mdc{SESSION_UUID}"
}
</pattern>
</pattern>
<!-- log guid support -->
<!-- StructuredArgument and Marker support -->
<!--
<arguments/>
<logstashMarkers/>
-->
<stackTrace>
<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
<maxDepthPerThrowable>10</maxDepthPerThrowable>
<maxLength>2048</maxLength>
<shortenedClassNameLength>32</shortenedClassNameLength>
<exclude>sun\.reflect\..*\.invoke.*</exclude>
<exclude>net\.sf\.cglib\.proxy\.MethodProxy\.invoke</exclude>
<rootCauseFirst>true</rootCauseFirst>
</throwableConverter>
</stackTrace>
</providers>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="jsonConsoleAppender" />
</root>
</configuration>
I cannot figured out how to get value from structured argument property in JSON pattern. I added for example StructuredArgument log.info(“sample log”, kv(“SAMPLE_KEY”, “TEST”)); Thank you for help in advance.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
[Logback Configuration XML] How to get StructuredArgument ...
I cannot figured out how to get value from structured argument property in JSON pattern. I added for example StructuredArgument log.info("sample ...
Read more >Structured Logging with Structured Arguments - INNOQ
First, we enable JSON logging in Spring Boot. Then, we discuss how to write log statements to benefit from the structured log format....
Read more >Structured logging with SLF4J and Logback - JRald Blog
In this article I will describe how to do structured logging in Java with usual logging libraries like SLF4J et Logback.
Read more >Java: How to log raw JSON as JSON and avoid escaping ...
To solve this, try the following in your logback.xml: ... (2016) groovy logback config that dumps out your logs in json format to...
Read more >How to Log in JSON with Logback - Mathieu Larose
The source code is available at https://github.com/larose/logback-json-example. End result: logger.debug("Hello world."); { "timestamp" : ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Unfortunately, the
pattern
provider does not support structured arguments.The
arguments
provider is the only provider that writes structured arguments.Output field order is determined by the order in which the
providers
are added. Therefore, all of the structured arguments are going to be together. You could putpattern
providers before and/or after them though.@philsttr Apologies in advance for resuming an old issue. Would it be possible to have a
marker
in thepattern
, instead? What I would like to achieve is to have a custom Marker/StructuredArgument serialized as usual to JSON but wrote as a string.