log/slog: Using SetDefault
causes level
and msg
being rendered wrong if log called in a panic recovery middleware
#64015
Labels
WaitingForInfo
Issue is not actionable because of missing required information, which needs to be provided.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
After sending a test request to HTTP endpoint to simulate panic and recovery, last log looks wrong.
Note: If you also use a custom log handler that extracts and adds custom fields to logs, none of those fields appear in logs either.
What did you see instead?
When used
NewJSONHandler
.When used
NewTextHandler
.As you can see above, the last log entry is not right!
If you omit
slog.SetDefault(slog.New(slog.NewJSONHandler(os.Stderr, nil)))
frommain
function, output seems correct for text version.The text was updated successfully, but these errors were encountered: