Your app writes free-text logs like `User 42 paid 19.99 in 340ms`. Why push for structured logging, and how?

BeginnerScenarioLogging Pipelines
Answer

Situation read → Free text forces regex parsing that breaks every time a developer edits a message. Queries become fragile.

What I'd do →

  1. Agree a JSON log schema: ts, level, msg, service, trace_id, span_id, plus event-specific fields.
  2. Switch to a structured logger (zap/slog in Go, structlog in Python, pino in Node, Logback JSON encoder in Java).
  3. Inject trace_id automatically from the OpenTelemetry context.
  4. Parse once in the shipper (json stage) and query fields directly.
{"ts":"2026-03-02T10:15:01Z","level":"info","msg":"payment completed","user_id":42,"amount":19.99,"duration_ms":340,"trace_id":"4bf92f3577b34da6"}

Why → Fields are stable contracts; message text is not.

Interview tip → Mention that user_id belongs in the log body, never as a Loki label.

All Monitoring & Observability questions Roadmap: Logging & tracing

More on Logging Pipelines