Prompt
Should I centralize logs or just keep them in each service?
Latest observation
Oct 28, 2026
OpenAI APIWeb search: off
Usually: centralize logs for anything beyond a very small system.
Best default
Keep local structured logs in each service, but ship them to a central system for search, alerting, and retention.
That gives you:
- easier debugging across services
- one place to query incidents
- better correlation with trace/request IDs
- simpler compliance/retention policies
- fewer “SSH into the box and grep” moments
When keeping logs only in each service is okay
It can be fine if:
- you have a single service or very small app
- you’re in early development/prototyping
- log volume is tiny
- you don’t need cross-service incident response
- cost/ops overhead must be minimal
Even then, I’d still recommend structured logs to stdout/stderr so they can be collected later if needed.
Recommended pattern
- Each service writes logs locally in a standard format, ideally JSON
- Include consistent fields like:
timestampserviceenvironmentlevelrequest_id/trace_iduser_idif appropriateerror_code
- Aggregate centrally with something like:
- ELK / OpenSearch
- Loki + Grafana
- Datadog
- Splunk
- Cloud provider logging
Practical rule of thumb
- Monolith or small app: local logs may be enough, but centralization is still a good idea
- Multiple services / production / distributed system: centralize
Don’t overdo it
Centralization is great, but avoid:
- dumping huge unstructured blobs
- logging sensitive data
- collecting everything forever without retention rules
If you want, I can also give you a decision matrix or a recommended logging setup for microservices.