<div dir="auto">Hi all<div dir="auto"><br></div><div dir="auto"><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;line-height:inherit;font-family:-apple-system,blinkmacsystemfont,"segoe ui adjusted","segoe ui","liberation sans",sans-serif;font-size:15px;vertical-align:baseline;color:rgb(35,38,41);background-color:rgb(255,255,255)">I'm trying to change the label in the log. I only want to get <code style="margin:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;vertical-align:baseline;white-space:pre-wrap">{"level":"WARNING","msg":"test"}</code> instead of <code style="margin:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;vertical-align:baseline;white-space:pre-wrap">{"level":"WARN","msg":"test"}</code>.</p><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;line-height:inherit;font-family:-apple-system,blinkmacsystemfont,"segoe ui adjusted","segoe ui","liberation sans",sans-serif;font-size:15px;vertical-align:baseline;color:rgb(35,38,41);background-color:rgb(255,255,255)">My class is:</p><pre style="margin-top:0px;border:0px;vertical-align:baseline;width:auto;max-height:600px"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;white-space:inherit"><span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">package</span> com.abc.def;
<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">import</span> org.slf4j.Logger;
<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">import</span> org.slf4j.LoggerFactory;
<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">import</span> org.springframework.boot.SpringApplication;
<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">import</span> org.springframework.boot.autoconfigure.SpringBootApplication;
<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">import</span> org.springframework.boot.builder.SpringApplicationBuilder;
<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">import</span> org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">@SpringBootApplication</span>
<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">public</span> <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">class</span> <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">Application</span> <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">extends</span> <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">SpringBootServletInitializer</span> {
<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">private</span> <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">static</span> <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">final</span> <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">Logger</span> <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">LOG</span> <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">=</span> LoggerFactory.getLogger(Application.class);
<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">@Override</span>
<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">protected</span> SpringApplicationBuilder <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">configure</span><span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">(SpringApplicationBuilder application)</span> {
<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">return</span> application.sources(Application.class);
}
<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">public</span> <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">static</span> <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">void</span> <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">main</span><span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">(String[] args)</span> {
LOG.warn(<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">"test"</span>);
SpringApplication.run(Application.class, args);
}
}
</code></pre><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;line-height:inherit;font-family:-apple-system,blinkmacsystemfont,"segoe ui adjusted","segoe ui","liberation sans",sans-serif;font-size:15px;vertical-align:baseline;color:rgb(35,38,41);background-color:rgb(255,255,255)">My logback.xml file is:</p><pre style="margin-top:0px;border:0px;vertical-align:baseline;width:auto;max-height:600px"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;white-space:inherit"><?xml version=<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">"1.0"</span> encoding=<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">"UTF-8"</span>?>
<configuration>
<property resource=<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">"application.properties"</span> />
<appender name=<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">"CONSOLE"</span> class=<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">"ch.qos.logback.core.ConsoleAppender"</span>>
<encoder class=<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">"net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder"</span>>
<providers>
<logLevel>
<fieldName>level</fieldName>
</logLevel>
<arguments>
<includeNonStructuredArguments><span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">false</span></includeNonStructuredArguments>
</arguments>
<stackTrace>
<fieldName>stack</fieldName>
</stackTrace>
<message>
<fieldName>msg</fieldName>
</message>
</providers>
</encoder>
</appender>
<root level=<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">"INFO"</span>>
<appender-ref ref=<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;font-size:13px;vertical-align:baseline">"CONSOLE"</span> />
</root>
</configuration>
</code></pre><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;line-height:inherit;font-family:-apple-system,blinkmacsystemfont,"segoe ui adjusted","segoe ui","liberation sans",sans-serif;font-size:15px;vertical-align:baseline;color:rgb(35,38,41);background-color:rgb(255,255,255)">I tried many changes but finally I don't any solution except creating a new class that extends net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder.</p><p style="margin:0px;padding:0px;border:0px;line-height:inherit;font-family:-apple-system,blinkmacsystemfont,"segoe ui adjusted","segoe ui","liberation sans",sans-serif;font-size:15px;vertical-align:baseline;color:rgb(35,38,41);background-color:rgb(255,255,255)">That seems a big stuff for a very small change.</p><p style="margin:0px;padding:0px;border:0px;line-height:inherit;font-family:-apple-system,blinkmacsystemfont,"segoe ui adjusted","segoe ui","liberation sans",sans-serif;font-size:15px;vertical-align:baseline;color:rgb(35,38,41);background-color:rgb(255,255,255)"><br></p><p style="margin:0px;padding:0px;border:0px;line-height:inherit;font-family:-apple-system,blinkmacsystemfont,"segoe ui adjusted","segoe ui","liberation sans",sans-serif;font-size:15px;vertical-align:baseline;color:rgb(35,38,41);background-color:rgb(255,255,255)">I posted already in stackoverflow <a href="https://stackoverflow.com/questions/72476767/how-to-change-the-log-level-label-with-slf4j">https://stackoverflow.com/questions/72476767/how-to-change-the-log-level-label-with-slf4j</a></p><p style="margin:0px;padding:0px;border:0px;line-height:inherit;font-family:-apple-system,blinkmacsystemfont,"segoe ui adjusted","segoe ui","liberation sans",sans-serif;font-size:15px;vertical-align:baseline;color:rgb(35,38,41);background-color:rgb(255,255,255)"><br></p><p style="margin:0px;padding:0px;border:0px;line-height:inherit;font-family:-apple-system,blinkmacsystemfont,"segoe ui adjusted","segoe ui","liberation sans",sans-serif;font-size:15px;vertical-align:baseline;color:rgb(35,38,41);background-color:rgb(255,255,255)">Thanks for helps</p></div></div>