A production-ready structured logging library for Python that is simple, powerful, and fast.
structlog is a structured logging library for Python that treats log entries as dictionaries processed through a chain of functions. It solves the problem of inflexible and low-performance traditional logging by providing a simple, powerful, and fast alternative designed for production environments.
Python developers building production applications who need reliable, performant, and flexible logging with support for structured output formats like JSON and logfmt.
Developers choose structlog because it combines simplicity with high performance, offers full control over log processing, integrates seamlessly with existing logging systems, and has been battle-tested at scale since 2013.
Simple, powerful, and fast logging for Python.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports JSON, logfmt, and pretty console rendering out-of-the-box, allowing easy switching between machine-readable and human-readable logs without custom code.
Built for speed by treating logs as dictionaries processed through efficient function chains, avoiding overhead common in traditional object-oriented logging systems.
Can forward logs to Python's standard logging module, enabling gradual adoption or coexistence with existing logging infrastructure.
Battle-tested since 2013 with support for modern Python features like asyncio and type hints, ensuring reliability at scale.
The flexibility requires upfront decisions on processors and renderers; beginners might find the lack of a single 'right way' confusing compared to more opinionated libraries.
Has fewer third-party extensions and integrations than Python's ubiquitous standard logging, potentially requiring custom code for niche backends or tools.
The functional, dictionary-based paradigm differs from object-oriented logging, which can be a hurdle for developers deeply familiar with traditional approaches.