Logging is a long established part of troubleshooting applications and one of the three pillars of observability, next to metrics and traces. No one likes flying blind in production, and when incidents happen, developers are happy to have log files. Logs are often written out in a human-readable format. Structured logging is a technique where the log output is written in a well-defined, often machine-readable format. This format can be fed into log management systems and enables powerful search and analytics capabilities. One of the most commonly used formats for structured logging is JSON. With Spring Boot 3.4, structured logging is supported out of the box. It supports the Elastic Common Schema (ECS) and Logstash formats, but it's also possible to extend it with your own formats. Let's jump straight in and see how it works! Structured logging Hello World Create a new project on start.spring.io. You don't need to add any dependencies, but make sure to select at least Spring Boot 3.4.0-M2. To enable structured logging on the console, add this to your application.properties: logging.structured.format.console=ecs This will instruct Spring Boot to log in the Elastic Common Schema (ECS) format. Now start the application, and you'll see that the log is formatted in JSON:…Read More
