# Task Plan: Structured Logging
## Goal
Switch to structured logging with tracing, add request ID to logs, support JSON output format.
**Source**: plan.md Step 8.2 (1-2 days)
## Phases
### Phase 1: Request ID
- [ ] Add request ID to all logs
- [ ] Use `#[instrument(skip_all, fields(request_id = %uuid::Uuid::new_v4()))]` or similar
- [ ] **Status:** pending
### Phase 2: Key Events
- [ ] Log: Request received (sanitized payload)
- [ ] Log: Provider call started
- [ ] Log: Provider call completed (with latency)
- [ ] Log: Response sent
- [ ] Log: Errors (with full context)
- [ ] **Status:** pending
### Phase 3: Log Levels
- [ ] DEBUG: Detailed request/response data
- [ ] INFO: Key operations
- [ ] WARN: Retries, fallbacks
- [ ] ERROR: Failures
- [ ] **Status:** pending
### Phase 4: JSON Output
- [ ] Support JSON output format
- [ ] Add config: `[server] log_format = "json"` or `"pretty"`
- [ ] **Status:** pending