Keeps this page in sync as the body changes. Pause it any time for a quieter view.
Path /specs/api-request-logging-middleware
Last refresh never
Spec: API Request Logging Middleware
inventory_source local | spec_api /api/spec-registry/api-request-logging-middleware | registry_updated 2026-04-09T03:10:08.815086Z
potential_value 0.00 | actual_value 1.00 | value_gap 0.00
estimated_cost 0.00 | actual_cost 1.00 | cost_gap 1.00
estimated_roi 0.00 | actual_roi 1.00
Missing contributor linkage. Submit a change request with contributor attribution.
Open process view for this spec
task_ids -
branches -
source_files specs/api-request-logging-middleware.md, specs/canonical-route-registry-and-runtime-mapping.md, specs/coherence-algorithm-spec.md, specs/postgresql-migration.md, specs/release-gates.md, specs/runtime-telemetry-db-precedence.md, specs/unified-sqlite-store.md, specs/universal-node-edge-layer.md
evidence_refs -
Open implementation view for this spec
implementation_refs spec-registry:api-request-logging-middleware, spec-registry:canonical-route-registry-and-runtime-mapping, spec-registry:coherence-algorithm-spec, spec-registry:postgresql-migration, spec-registry:release-gates, spec-registry:runtime-telemetry-db-precedence, spec-registry:unified-sqlite-store, spec-registry:universal-node-edge-layer
lineage_ids -
public_endpoints -
summary Add structured access-log middleware that records every API request with method, path, status code, and duration. This provides a consistent, queryable request log for debugging, performance monitoring, and audit trails. Without it, operators must piece together information from multiple log sources or rely solely on the slow-request threshold logger, which misses normal-latency requests entirely.
process_summary Every HTTP request produces exactly one structured log line after the response is sent.; Each log line includes: HTTP method, request path, response status code, and request duration in milliseconds.; Log level is `INFO` for 2xx/3xx responses and `WARNING` for 4xx/5xx responses.; Health-check endpoints (`/api/health`, `/healthz`) are excluded from logging to avoid noise.; The middleware is configurable via an environment variable `API_ACCESS_LOG_ENABLED` (default `"1"`; set to `"0"` to disa
pseudocode_summary -
implementation_summary api/app/middleware/request_duration.py (RequestDurationMiddleware); api/app/main.py (middleware registration)