structlog#

Simple. Powerful. Fast. Pick three.

Release 24.1.0 (What’s new?)


structlog is the production-ready logging solution for Python:

  • Simple: Everything is about functions that take and return dictionaries – all hidden behind familiar APIs.

  • Powerful: Functions and dictionaries aren’t just simple but 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 logging module.

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:

image

Sponsors#

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!

Basics#

The first chapters teach you all you need to use structlog productively. They build gently on each other, so ideally, read them in order. If anything seems confusing, don’t hesitate to have a look at our Glossary!

Development Affordances#

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.

Reference#

Deprecated Features#

Indices and tables#