23 / 67 · 06 Observability-Driven Testing · Structured Logging Best Practices← prev⊞ allnext →☰ Read as one page
4.4Essential Fields for Every Log Entry
| Field | Required? | Purpose |
|---|---|---|
timestamp |
Yes | When the event occurred (ISO 8601) |
level |
Yes | Severity (debug, info, warn, error) |
service |
Yes | Which service emitted the log |
event |
Yes | Machine-readable event name (snake_case) |
trace_id |
Yes | Correlation with distributed traces |
span_id |
Recommended | Correlation with specific trace span |
environment |
Recommended | production, staging, development |
version |
Recommended | Application version for deployment correlation |
user_id |
When available | User attribution (hashed for PII compliance) |
request_id |
Recommended | Correlation within a single request |