-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Graylog Extended Log Format (GELF) for structured logging #42158
Add Graylog Extended Log Format (GELF) for structured logging #42158
Conversation
- Add `gelf` structured logging formatter with Logback - Add `gelf` structured logging formatter with Log4j2 - Describe GELF Formatter in the logging documentation - Add `logging.structured.gelf.service.*` properties to `additional-spring-configuration-metadata.json`
@slissner Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@slissner Thank you for signing the Contributor License Agreement! |
...-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/features/logging.adoc
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I've left a few comments for your consideration.
.../org/springframework/boot/logging/log4j2/GraylogExtendedLogFormatStructuredLogFormatter.java
Show resolved
Hide resolved
...org/springframework/boot/logging/logback/GraylogExtendedLogFormatStructuredLogFormatter.java
Show resolved
Hide resolved
.../org/springframework/boot/logging/log4j2/GraylogExtendedLogFormatStructuredLogFormatter.java
Show resolved
Hide resolved
.../org/springframework/boot/logging/log4j2/GraylogExtendedLogFormatStructuredLogFormatter.java
Show resolved
Hide resolved
Thank you very much and congratulations on your first contribution 🎉! I've polished a bit in b5e7302, for example fixing the double timestamp formatting. |
Thank you very much @mhalbritter for finalizing this!! I wanted to work on your issues this Friday, but you were faster :) Awesome to see GELF integrated with Spring Boot. |
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