fix: use structured logging for startup errors#235
Merged
jrobotham-square merged 1 commit intomainfrom Mar 30, 2026
Merged
Conversation
Startup errors after the slog logger is initialized (config loading, metrics, server creation) were using kong's FatalIfErrorf, which writes plain unstructured text to stderr. Log aggregation systems cannot extract a log level from these messages, making them difficult to find and alert on. Switch post-logger-init fatal errors to use slog.ErrorContext so they are emitted as structured logs with a proper ERROR level. Pre-logger errors (HCL parsing, global config) remain on kong since the logger isn't available yet. Amp-Thread-ID: https://ampcode.com/threads/T-019d3c97-9bcd-753d-bea7-bb117983acd6 Co-authored-by: Amp <amp@ampcode.com>
stuartwdouglas
approved these changes
Mar 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Startup errors after the slog logger is initialized (config loading, metrics, server creation) were using kong's
FatalIfErrorf, which writes plain unstructured text to stderr. Log aggregation systems cannot extract a log level from these messages, making them hard to filter and alert on.This switches post-logger-init fatal errors to use
slog.ErrorContextso they are emitted as structured logs with a properERRORlevel. Pre-logger errors (HCL parsing, global config) remain on kong since the logger isn't available yet.