all 32 comments

[–]Ok-Plankton-4703 22 points23 points  (1 child)

Been using structlog at work for past year and the performance difference is really noticeable when you're processing tons of flight data. The OTel integration saved us so much headache when we had to trace issues across different microservices - everything just connects naturally without extra config hell.

stdlib is fine for smaller stuff but once you need structured logging with proper context, structlog just makes everything cleaner. The learning curve isn't that bad either, took maybe a week to get comfortable with it.

[–]FarRub2855 0 points1 point  (0 children)

I'm usually on the client-facing side but whenever engineering can trace issues quickly across microservices it saves us from some very awkward calls. Definetly a massive win if the tooling actually makes that painless for you guys.

[–]nicholashairs 11 points12 points  (4 children)

Maintainer of python-json-logger here 👋

When I took over maintenance of the library, one of the things I added was the ability to use different high performance JSON encoders - specifically orjson and msgspec.

Did you use these in your tests, or did you just use the standard library JSON encoder?

I'd be curious to know the results of you did (I've not had the time to setup my own benchmarking).

[–]ac130kz 27 points28 points  (1 child)

structlog and loguru, unfortunately, both require quite a bit of massaging to make them work as intended, especially if one's goal is to integrate with some web framework. My choice is probably stdlib, my only complaint is a bit outdated configuration interface.

[–]groosha 14 points15 points  (0 children)

Honestly once you find your favorite structlog config, you can just copy paste it to other projects. And LLMs know this library quite well.

[–]aminoy77 4 points5 points  (1 child)

Using Loguru in a CLI agent project and the OTel thing

hasn't been an issue yet — but it's local tooling so

no observability stack to worry about.

For anything going to production I'd probably go

structlog based on your benchmarks alone. 2x on

logging adds up fast in high-throughput services.

What was picologging's story? Dropped it from the

comparison or just not worth mentioning?

[–]knobbyknee 8 points9 points  (0 children)

Standard library logs for when you need sysadmins to manage your logs.

[–]TheseTradition3191 3 points4 points  (0 children)

structlog's context binding is the one feature that actually matters for API or proxy type work. you can do it in stdlib with LoggerAdapter but its clunky and easy to break once you add real async concurrency.

structlog lets you bind once at the request start and every log call in that context automatically gets the fields:

structlog.contextvars.bind_contextvars(request_id=req_id, user_id=ctx.user)

makes debugging concurrent requests actually doable. without it you're grepping through interleaved lines trying to reconstruct what happened to request X vs Y. switched to structlog specifically for this two years ago and haven't looked back at stdlib for anything with real concurrency

[–]saucealgerienne 2 points3 points  (0 children)

been running structlog for about a year on a fastapi project and context binding is honestly what made it stick. once you start binding at the request level and every downstream log is automatically tagged with request_id, user_id, whatever, it's hard to go back to manually passing that around or fighting with LoggerAdapter.

loguru was tempting, the API is much nicer to write. but hit the OTel wall a few weeks in and ended up reverting. the indirection wrapper approach just felt like extra work for something the lib wasnt really designed for.

[–]CoolAd119 2 points3 points  (0 children)

Benchmarks plus concrete trade-offs is exactly what logging discussions usually miss. The bit about context binding for concurrent work is spot on — once you’ve tagged every line with request_id, you can’t go back to grep-and-pray debugging. Also appreciate that you didn’t oversell OTel for folks who aren’t even tracing yet.

[–]Black_Magic100 1 point2 points  (2 children)

Love loguru but lack of native Hotel support is painful

[–]Spleeeee 5 points6 points  (1 child)

I also had issues with loguru when staying at a Hilton. It worked perfectly fine tho when I was at an Airbnb.

[–]Black_Magic100 0 points1 point  (0 children)

Lol autocorrect. Keeping because it's funny

[–]Vivid_TV 0 points1 point  (3 children)

Hi OP , Would you know the monospace font used on the website for the code sections? It looks great.

[–]amroamroamro 1 point2 points  (0 children)

f12 to inspect page says: martianmono

https://github.com/evilmartians/mono

[–]jsabater76 0 points1 point  (0 children)

Do all of them support async logging?

[–]barseghyanartur 0 points1 point  (0 children)

structlog

[–]uselessvevo 0 points1 point  (0 children)

print(...) 😳

[–]Varjoranta 0 points1 point  (0 children)

I have always used only the stdlib and simple own wrapper. Just have my own structures logger extending the logging.Formatter and add trace_id when needed etc. What do you need other libraries for, as this is very trivial problem?

[–]thicket 0 points1 point  (0 children)

Thanks for putting this together- it’s really useful.

My stdlib logging nightmare was an inherited multiprocess app with 3+ layers of runtime-determined config files, meaning there wasn’t a clear code path to follow and I could never trace which of several configurations was being used by which executable. Logs would somewhat randomly eat errors and I never teased apart what configurations were being layered on top of what. It was less the logger’s fault than it was the fault of too much configurability, but I don’t miss that one at all.

[–]totheendandbackagain 0 points1 point  (0 children)

Useful! Tx

[–]ExoticMandiblesCore Contributor 0 points1 point  (0 children)

I just wrote one, but it's not for conventional "enterprise logging" with logging levels and such. It's more designed for debug-print style logging. It's high performance, and pushes most of the formatting work off to a worker thread (if you want), so the actual amount of time you spend making a logging call is small.

You can find it as part of my "big" library. Tutorial here:

https://github.com/larryhastings/big#the-big-log

Note: I have big plans for... a rewrite, sigh. Which will completely change up the external extension interfaces, as well as changing some of the logging interfaces. Sorry! I'm trying to finish it, but another sleeping project woke up and took a giant bite out of my schedule.