Fapilog - Batteries-included, async-first logging for Python services
fapilog is a high-performance logging pipeline that eliminates the bottlenecks of traditional Python logging. By replacing blocking I/O with a lock-free, async-native architecture, it ensures your application never stalls to write a log. While it’s an excellent choice for FastAPI and microservices, its lightweight footprint and pluggable sinks make it equally powerful for on-prem, desktop, or embedded projects.
Stability: Core logger and FastAPI middleware are beta/stable under semver.
Why Fapilog?
Traditional logging libraries block your application, lose context, and produce unstructured output. Fapilog gives you:
Async-first - Never block your application again
Structured - JSON logs that machines can actually parse
Production-ready - Built-in redaction, metrics, and resilience
High-performance - Lock-free queues and zero-copy processing
Read more about why fapilog → | See all features → | Compare with alternatives →
Quick Example
from fapilog import get_async_logger
# Zero-config, works immediately (async)
logger = await get_async_logger()
await logger.info("User logged in", user_id="123")
# Automatic context binding
await logger.error("Database connection failed", exc_info=True)
Output:
{"timestamp": "2024-01-15T10:30:00.123Z", "level": "INFO", "message": "User logged in", "user_id": "123"}
{"timestamp": "2024-01-15T10:30:01.456Z", "level": "ERROR", "message": "Database connection failed", "exception": "..."}
Get Started
Quickstart Tutorial - Get logging in 2 minutes
Installation Guide - Setup and configuration
API Reference - Complete API documentation
Who It’s For
Backend developers building APIs and microservices
Data engineers running pipelines and ETL jobs
DevOps teams managing infrastructure and monitoring
Anyone who’s tired of logging slowing down their Python apps
Documentation Sections
Documentation
- Getting Started
- Why fapilog?
- Features
- Python Logging Library Comparison
- Core Concepts
- User Guide
- Configuration
- Configuration Presets
- Execution Modes
- Configuring Fapilog with the Builder API
- Environment Variable Configuration
- Production Checklist
- Using the Logger
- Context Enrichment
- Rotating File Sink
- Sink routing by level
- Circuit Breaker
- Adaptive Pipeline
- Sampling Strategies
- Graceful Shutdown
- Performance Tuning
- Performance Benchmarks
- Integration Guide
- stdlib Logging Bridge
- FastAPI / ASGI Integration
- Reliability Defaults and Guardrails
- Testing Plugins
- Webhook Security
- Cookbook
- FastAPI Microservices in Production
- FastAPI JSON logging to stdout (Uvicorn access logs included)
- FastAPI request_id logging (correlation ID middleware, concurrency-safe)
- Django Structured JSON Logging with Correlation IDs
- Non-blocking logging in FastAPI (protect latency under slow sinks)
- One FastAPI logging config for dev + prod (Uvicorn/Gunicorn)
- Redacting secrets and PII in FastAPI logs (Authorization, tokens, fields)
- Compliance Redaction: What Works and What Doesn’t
- Logging request/response bodies without hanging (safe patterns)
- Skipping health/metrics endpoints (noise reduction)
- Log sampling and rate limiting for FastAPI
- Adaptive Sampling for High-Volume Services
- Graceful shutdown & flushing logs (don’t lose logs on deploy)
- Exception logging in FastAPI with request_id + structured context
- Custom log levels in Python (TRACE, VERBOSE, NOTICE)
- Examples & Recipes
- Redaction
- Enterprise Features
- API Reference
- Plugin Development
- Integration Patterns
- Troubleshooting
- Frequently Asked Questions
- Appendices
- Environment Variables
- Settings Reference
- Schema Guide
- Schema Migration Guide: v1.0 to v1.1
- Plugin Catalog
- Security Remediation & Approval Workflows
- Quality Signals
- Migrating from Settings to Builder
- Migration Guide: Simplified Rotating File Setup
- Tenacity Integration Guide
- Testing with Fapilog
- Async Context Propagation
- Tamper-Evident Logging Add-on (Optional)
Start Here:
Getting Started - Installation and quickstart
Core Concepts - Understanding the architecture
User Guide - Practical usage and configuration
Cookbook - Focused recipes for common problems
Examples - Real-world usage patterns
Production Ready:
Redaction - Protect sensitive data (GDPR, HIPAA, PCI-DSS)
Enterprise Features - Compliance, audit trails, and security
Reference:
API Reference - Complete API documentation
Examples - Real-world usage patterns
Troubleshooting - Common issues and solutions
FAQ - Frequently asked questions
Development:
Contributing - How to contribute to fapilog
Release Notes - Changelog and upgrade guides
Appendices - Glossary, architecture diagrams, and license
If fapilog is useful to you, consider giving it a star on GitHub — it helps others discover the library.