Problem
Current logs are human-readable but not machine-parseable. Log aggregators (Loki, CloudWatch, Datadog) need structured JSON. Trace IDs in every log line enable correlating logs with traces.
Proposed solution
- Replace NestJS default logger with
pino or winston configured for JSON output
- Every log line includes: timestamp, level, message, correlationId, traceId, spanId, module, extra context
- Request logging middleware adds: method, path, status, duration, userId, tenantId
- Kafka consumer logs add: topic, partition, offset, consumerGroup
- Development mode: pretty-printed. Production mode: single-line JSON.
API design (if applicable)
No API change. Log format change.
Alternatives considered
- Keep NestJS default logger — rejected. Not structured, no JSON, no trace IDs.
- Bunyan — rejected. Pino is faster and more actively maintained.
Additional context
Add Loki to docker-compose.yml for local log aggregation. Query via Grafana.
Problem
Current logs are human-readable but not machine-parseable. Log aggregators (Loki, CloudWatch, Datadog) need structured JSON. Trace IDs in every log line enable correlating logs with traces.
Proposed solution
pinoorwinstonconfigured for JSON outputAPI design (if applicable)
No API change. Log format change.
Alternatives considered
Additional context
Add Loki to
docker-compose.ymlfor local log aggregation. Query via Grafana.