Structured Logging

When you log something, make it searchable and analyzable.

Structured logging is a programming practice of implementing a consistent, predetermined message format for application logs that allows the logs to be treated as datasets, which makes them amenable to search, and analysis to gather insights about application behaviour and performance.

Most programming languages and frameworks have libraries that make it easy to do structured logging.

Common Structured Logging formats are JSON(line) and key=value separated by white-space.

Structured logging in Go with slog – interesting thing I learnt from this library - “nested keys”.

Tracing: structured logging, but better in every way | Andy Dote