Logs and observability
Logs exist to find a production problem in minutes. One format, named fields, JSON on stdout with a traceId born in the front-end, Loki to search, Grafana to see and alert. Business auditing is something else and lives in a table.
Decisions and why
- One format: [Class]: message - [Field]: value
- You can search [OperationId] across every service. Nobody writes "User ID:" one way and "userId" another.
- Controllers log start and end; use cases log the outcome and every refusal
- Every 4xx has a line explaining why, written before the exception.
- JSON on stdout + Loki, no files
- stdout is the sink that cannot fail; Loki is where you search. A rolling file in a container is a lost log.
- traceparent minted in the front-end
- One user request becomes one traceId across every service and queue.
- Audit in logs.audit
- Who did what to whom, with ip and user agent, is queryable business data, not a log line that expires.
requestresponse
Pick a scenario above to watch the message travel through the architecture.