fapilogYour sinks can be slow. Your app shouldn't be.

Async-first structured logging for Python—built to be the perfect companion for FastAPI microservices.

fapilog pushes log I/O off the hot path, applies controlled backpressure, and ships with production-ready redaction.

FastAPI-first. Works everywhere Python runs.

pip install fapilog

Quick Start

Get structured logging in your FastAPI app in under a minute.

main.py
from fastapi import Depends, FastAPI
from fapilog.fastapi import FastAPIBuilder, get_request_logger

app = FastAPI(
    lifespan=FastAPIBuilder()
        .with_preset("production")
        .build()
)
# Automatically logs every request (method, path, status, latency) with correlation_id for tracing

@app.get("/users/{user_id}")
async def get_user(user_id: int, logger=Depends(get_request_logger)):
    await logger.info("Fetching user", user_id=user_id)
    return {"user_id": user_id}

See the full quickstart guide for more examples.

Why fapilog?

  • Latency stays stable

    Log work is queued; sinks happen off the hot path. Slow destinations don't block your request handlers.

  • Structured JSON logging

    Every log entry is a structured JSON object. Perfect for log aggregators, search, and analysis.

  • FastAPI-first integration

    Designed to be the default logger for FastAPI microservices. Request logging and correlation IDs without boilerplate.

  • Predictable under overload

    Choose your backpressure policy: prioritize latency or durability when logs arrive faster than sinks can write.

  • Production-ready safety

    Built-in PII redaction masks sensitive data automatically. Clean shutdown drains queues so logs aren't lost.

  • Cloud-native sinks

    Native integrations for CloudWatch, Loki, PostgreSQL, and stdout. Route logs where they need to go.

  • Extensible pipeline

    Bring your own sinks, filters, processors, enrichers, and redactors. No marketplace—just clean extension points.

  • Request correlation

    Automatic correlation IDs track requests across your distributed system. Trace issues end-to-end.

fapilog pipeline architecture diagram showing the hot path for fast enqueue and off hot path for sink I/O
Apache 2.0 Licensed
Open Source
FastAPI-Focused
Python 3.10+