Access Logging — Aquilia Documentation
Comprehensive guide and documentation for Access Logging in the Aquilia framework. View API reference, examples, and implementation patterns.
MIDDLEWARE / ACCESS LOGGING LoggingMiddleware The LoggingMiddleware handles high-performance HTTP access logging. It supports multiple layout formatters, timing tracking with microsecond precision, and slow request alerting. Constructor Configuration The middleware constructor accepts several parameters to customize how access logs are gathered: logger_name: str = "aquilia.access" — The logger instance name used to dispatch output. format: str = "dev" — The log line template. Select from "dev" (color-coded terminal), "combined" (standard Nginx/Apache Combined Log Format), or "structured" (JSON output for observability aggregators). slow_threshold_ms: float = 1000.0 — Warns (at Warning log level) if a request duration exceeds this value. skip_paths: set[str] | None = None — Paths excluded from logging (defaults to "}). log_request_body: bool = False — Captures and logs request body byte length. include_headers: list[str] | None = None — List of HTTP request headers to extract and append to the log line extras. Usage Example from aquilia.middleware_ext import LoggingMiddleware from aquilia.workspace import Workspace from aquilia.integrations import MiddlewareChain workspace = ( Workspace("myapp") .middleware( MiddlewareChain() .use( "aquilia.middleware_ext.logging:LoggingMiddleware", priority=20, format="structured", # JSON outputs slow_threshold_ms=500.0, # Alert on delays > 500ms include_headers=["User-Agent", "Referer"] ) ) ) Overview )
Go to Homepage