[Python-announce] structlog 22.2.0

Skip to first unread message

Hynek Schlawack

Nov 19, 2022, 8:47:35 AM11/19/22
I’m happy to announce a new release of structlog!

With more than 4 million downloads per month, structlog is the best solution for production-ready structured logging in Python. It doesn’t just allow you to log key-value pairs in a structured manner, it also makes it EASIER and FASTER. Check out <https://www.structlog.org/en/stable/why.html> if you’re intrigued but not convinced!


This is another (too) big release, but before I go into new features, allow me to beg you to check out structlog's documentation: <https://www.structlog.org/>.

I've spent easily half of the time on bringing is up to date, restructuring, and adding usage recipes. Not new in this release, but did you know that the standard library chapter has flowcharts that give you as visual explanations of how the various methods work? This is usually the biggest sticking point when starting to use structlog.

Feature-wise the big thing is that structlog's internal (and extremely fast) loggers (the one created using structlog.make_filtering_bound_logger() got two new features that people have asked for forever:

1. String interpolation: log.info("hello %s!", "world") works now!
2. Async! Each logging method has an async version: await log.ainfo("hello %s!", "world") is the same thing as above, but async.

Special Thanks

This release would not be possible without my generous sponsors! Thank you to all of you making sustainable maintenance possible! If you would like to join them, go to https://github.com/sponsors/hynek and check out the sweet perks!

Above and Beyond

Variomedia AG (@variomedia), Tidelift (@tidelift), Sentry (@getsentry), HiredScore (@HiredScore), FilePreviews (@filepreviews), and Daniel Fortunov (@asqui).

Maintenance Sustainers

@rzijp, Adam Hill (@adamghill), Dan Groshev (@si14), Tamir Bahar (@tmr232), Adi Roiban (@adiroiban), Magnus Watn (@magnuswatn), David Cramer (@dcramer), Moving Content AG (@moving-content), Stein Magnus Jodal (@jodal), Iwan Aucamp (@aucampia), ProteinQure (@ProteinQure), Jesse Snyder (@jessesnyder), Rivo Laks (@rivol), Thomas Ballinger (@thomasballinger), @medecau, Ionel Cristian Mărieș (@ionelmc), The Westervelt Company (@westerveltco), Philippe Galvan (@PhilippeGalvan), Birk Jernström (@birkjernstrom), Jannis Leidel (@jezdez), Tim Schilling (@tim-schilling), Chris Withers (@cjw296), and Christopher Dignam (@chdsbd).

Not to forget 2 more amazing humans who chose to be generous but anonymous!

Full Changelog


- Accessing package metadata as attributes on the structlog module is deprecated (e.g. structlog.__version__). Please use importlib.metadata instead (for Python 3.7: the importlib-metadata PyPI package).
- The structlog.types module is now deprecated in favor of the structlog.typing module. It seems like the Python typing community is settling on this name.


- FilteringBoundLogger (used by default) now allows for string interpolation using positional arguments:

>>> log.info("Hello %s! The answer is %d.", "World", 42, x=1)
2022-10-07 10:04.31 [info ] Hello World! The answer is 42. x=1


- FilteringBoundLogger now also has support for asyncio-based logging. Instead of a wrapper class like structlog.stdlib.AsyncBoundLogger, async equivalents have been added for all logging methods. So instead of log.info("hello") you can also write await log.ainfo("hello") in async functions and methods.

This seems like the better approach and if it's liked by the community, structlog.stdlib.BoundLogger will get those methods too. #457


- The documentation has been heavily overhauled. Have a look if you haven't lately! Especially the graphs in the standard library chapter have proven valuable to many.
- The build backend has been switched to Hatch.


- The timestamps in the default configuration now use the correct separator (:) for seconds.

Reply all
Reply to author
0 new messages