Why Structured Logs
Machine-readable logging.
Logs Machines Can Read
Traditional logs are free-form strings: "user 42 logged in from 1.2.3.4". They are easy for humans but painful for machines to query. Structured logging emits key-value pairs so log aggregators can filter and aggregate reliably.
The Problem With String Logs
Parsing free text is brittle:
- Formats drift over time
- Regexes break on edge cases
- You cannot easily ask "all events where userID=42"
Structured logs make every field a first-class, queryable attribute.
All lessons in this course
- Why Structured Logs
- slog Handlers
- Log Levels and Attributes
- Custom Handlers