freecoding.school100% FREE · NO SIGNUP
Gateway RidgeISSUE #21 of 35

logging · structured json · levels

Gateway GusVSTimeout Titan
Gateway Gus saysStructured logging emits machine-parseable JSON with levels and a correlation id.

Plain text logs are hard to search at scale. Structured logs emit JSON ({ level, msg, requestId, userId, ... }) so log systems can filter and aggregate. Use levels (debug/info/warn/error) to control verbosity, and include a correlation id so you can trace one request's logs across services. Never log secrets or full payloads with PII.

Power-ups you unlock

Timeout Titan attacks — common mistakes

Boss battleDesign a structured log line for a failed login attempt.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre>{ "level":"warn", "msg":"login_failed",
  "requestId":"abc123", "email":"d***@x.com",
  "reason":"bad_password" }   ← no raw password</pre></body></html>
▶ Open the interactive comic issue
‹ Metrics · Histograms · Counters · GaugesTesting Apis · Contract Testing · Pact ›