0PricingLogin
Go Academy · Lesson

Log Levels and Attributes

Add context to logs.

Adding Context to Logs

A bare message tells you what happened; attributes tell you the details that make logs actionable: which user, which request, how long it took.

The Four Levels

slog levels, lowest to highest severity:

  • Debug (-4)
  • Info (0)
  • Warn (4)
  • Error (8)

Levels are integers, so you can define custom ones in between.

All lessons in this course

  1. Why Structured Logs
  2. slog Handlers
  3. Log Levels and Attributes
  4. Custom Handlers
← Back to Go Academy