Simple. Powerful. Fast. Pick three.
Release 22.3.0 (What’s new?)
structlog is the production-ready logging solution for Python:
Simple: At its core, everything is about functions that take and return dictionaries – all hidden behind familiar APIs.
Powerful: Functions and dictionaries aren’t just simple, they’re also powerful. structlog leaves you in control.
Fast: structlog is not hamstrung by designs of yore. Its flexibility comes not at the price of performance.
Thanks to its flexible design, you choose whether you want structlog to take care of the output of your log entries or whether you prefer to forward them to an existing logging system like the standard library’s
The output format is just as flexible and structlog comes with support for JSON, logfmt, as well as pretty console output out-of-the-box:
structlog would not be possible without our amazing sponsors. Especially those generously supporting us at the The Organization tier and higher:
Please consider joining them to help make structlog’s maintenance more sustainable!
structlog has been successfully used in production at every scale since 2013, while embracing cutting-edge technologies like asyncio, context variables, or type hints as they emerged. Its paradigms proved influential enough to help design structured logging packages across ecosystems.
If you’d like more information on why structured logging in general – and structlog in particular – are good ideas, we’ve prepared a summary just for you.
Otherwise, let’s dive right in!
The first chapters teach you all you need to use structlog productively. They build gently on each other, so ideally, read them in order.
- Getting Started
- Bound Loggers
- Context Variables
structlog’s focus is production systems, but it comes with pretty console logging and handy in-development helpers both for your comfort and your code’s quality.
Integration with Existing Systems#
structlog is both zero-config as well as highly configurable. You can use it on its own or integrate with existing systems. Dedicated support for the standard library and Twisted is shipped out-of-the-box.
structlog in Practice#
The following chapters deal with considerations of using structlog in the real world.
License: dual Apache License, version 2 and MIT
Get Help: please use the structlog tag on Stack Overflow
Supported Python Versions: 3.7 and later
structlog for Enterprise#
Available as part of the Tidelift Subscription.
The maintainers of structlog and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. Learn more.