Fapilog — async-first logging for Python
Structured logging for Python services where blocking I/O isn't an option. Built for FastAPI, microservices, and high-throughput async applications.
pip install fapilogQuick Start
Get structured logging in your FastAPI app in under a minute.
from fastapi import FastAPI
from fapilog.fastapi import setup_logging
app = FastAPI(lifespan=setup_logging(preset="production"))
@app.get("/")
async def root():
return {"message": "Hello World"}
# Requests are logged automatically with correlation IDsSee the full quickstart guide for more examples.
Why Fapilog
Async-native by design
Built for async Python from the ground up. Non-blocking I/O means your logs never slow down your requests.
Structured JSON logging
Every log entry is a structured JSON object. Perfect for log aggregators, search, and analysis.
FastAPI-native integration
First-class FastAPI support with automatic request/response logging and correlation IDs.
Backpressure handling
Choose what happens when logs arrive faster than sinks can write: drop, wait, or discard oldest.
Built-in PII redaction
Passwords, emails, and secrets are masked automatically with the production preset. No compliance surprises.
Cloud-native sinks
Native integrations for CloudWatch, Loki, PostgreSQL, and stdout. Route logs where they need to go.
Level-based routing
Send errors to a database for alerting while debug logs go to stdout. Route by level, not just globally.
Request correlation
Automatic correlation IDs track requests across your distributed system. Trace issues end-to-end.