Each log line will be a JSON object with fields like @timestamp, @version, message, logger_name, thread_name, level, and stack traces as structured arrays. If you need to customize which fields appear or add MDC context, the LogstashEncoder supports extensive configuration via nested elements in the appender.
pom.xml
<!-- Structured JSON logging (Logback JSON encoder) -->
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>9.0</version>
</dependency>
src/main/resources/logback-spring.xml
Only output to console desired, no logging to file
<?xml version="1.0" encoding="UTF-8"?>
<!-- WARNING Since Spring Boot 2.1.11.RELEASE, logback-spring.xml must exist at both:
-src/main/resources/
-src/test/resources/
-->
<configuration>
<appender name="CONSOLE_JSON" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
</appender>
<!-- Enable DEBUG (or TRACE) only for tests
<logger name="edu.cou" level="DEBUG"/> -->
<root level="INFO">
<appender-ref ref="CONSOLE_JSON"/>
</root>
</configuration>