Slog

structured logging: slog

Event logging is one of the three pillars of observability (traces and metrics being the other two).

A log entry is a timestamped record about the application’s activity, which can be used for troubleshooting, monitoring or auditing purposes.

Logs may have different formats:

  • unstructured or plain text: similar to print statements, free-form text
  • semi-structured: some values have a structure and the remaining data free-form
  • structured: there is a well-defined and consistent format, such as: W3C Log Format, NCSA Log Format, Key/Value Pair, CSV or JSON, among others. Structured logs can be easily machine parsed, which simplifies analytics, filtering and aggregation.

This article is a non-exhaustive walkthrough of logging in Go.