22 lines
622 B
Markdown
22 lines
622 B
Markdown
|
|
# Structured Logging
|
||
|
|
|
||
|
|
## Status
|
||
|
|
|
||
|
|
Accepted
|
||
|
|
|
||
|
|
## Context
|
||
|
|
|
||
|
|
For operational debugging, structured logs are needed for API errors and security events. This includes timestamps, log levels, request IDs, and routes.
|
||
|
|
|
||
|
|
## Decision
|
||
|
|
|
||
|
|
We implement a centralized logging middleware that:
|
||
|
|
1. Logs all requests with timestamp, method, URL, request ID, and route
|
||
|
|
2. Logs error responses with correlation via request ID
|
||
|
|
3. Marks security-relevant events (401, 403) separately
|
||
|
|
|
||
|
|
## Consequences
|
||
|
|
|
||
|
|
- Logs are structured and filterable
|
||
|
|
- Security events can be easily identified
|
||
|
|
- Debugging is improved through correlation of requests and errors
|