Add Graylog Extended Log Format (GELF) for structured logging #42158
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Summary
As of Spring Boot v3.4, structured logging is now built-in into Spring Boot.
The following pull requests adds a Graylog Extended Log Format (GELF) formatter to the structured logging of Spring Boot.
Features
gelf
structured logging formatter with Logbackgelf
structured logging formatter with Log4j2logging.structured.gelf.service.*
properties toadditional-spring-configuration-metadata.json
Examples
Log messages
Example INFO log in GELF format:
Example ERROR log with stack trace in GELF format:
Screenshots
Search Dashboard
INFO log:
ERROR log:
Local Testing
In order to test this pull request locally, please have a look at the following demo applications:
Only the demo application for Logback is set up to actually send logs to a local Graylog instance. It uses an UDP log appender from the https://github.com/osiegmar/logback-gelf library.
Please see the above mentioned repository for further explanation on how to set up quickly a local instance of Graylog.
See also