Skip to main content
InterviewHubPRO
Section Overview
Q36

Question 36 of 50

Part 3: Go Microservices, HTTP, gRPC & Architecture (33 - 44)

72%
Golang & Concurrency (50 Qs)•Part 3: Go Microservices, HTTP, gRPC & Architecture (33 - 44)

Structured Logging with `log/slog` (Go 1.21+).

senior LevelCode ExampleSystem DesigngRPCMicroservices

In Simple Words: Go 1.21 introduced log/slog as the official high-performance structured logging standard:

go
import "log/slog"

logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
slog.SetDefault(logger)

slog.Info("Order processed successfully",
	slog.String("order_id", "ord_9981"),
	slog.Float64("amount", 149.50),
	slog.Int("attempts", 1),
)