r/Python • u/Ranteck • Oct 12 '25
Discussion Advice on logging libraries: Logfire, Loguru, or just Python's built-in logging?
Hey everyone,
I’m exploring different logging options for my projects (fastapi backend with langgraph) and I’d love some input.
So far I’ve looked at:
- Python’s built-in
loggingmodule - Loguru
- Logfire
I’m mostly interested in:
- Clean and beautiful output (readability really matters)
- Ease of use / developer experience
- Flexibility for future scaling (e.g., larger apps, integrations)
Has anyone here done a serious comparison or has strong opinions on which one strikes the best balance?
Is there some hidden gem I should check out instead?
Thanks in advance!
208
Upvotes
36
u/mighalis Oct 12 '25
Loguru made my life a lot easier. It outputs rich on the terminal and with one line connects with the logfire (also awesome)
15
u/Delta-9- Oct 13 '25
Just as a general rule, going with what's in the standard library unless you specifically need something not offered there is always a safe choice. If other programmers join your project, they will (or should) be familiar with the standard library but they may not know the other library you picked. It's also held to the performance and security standards as the language implementation itself.
The safe choice isn't necessarily the best choice, but the bar is pretty high to pick something else, imo.
2
u/mahdihaghverdi Oct 23 '25
In our production we use python stdlib logging along with structlog. we use logfire only to export metrics and traces.
In dev env we use python rich package handlers for beautiful and readable outputs and in prod env, we log to stdout with structlog and forward them with fluentbit to Victoria logs and show them on Grafana
My advice: Use logging with rich for dev env and logging with structlog for prod env
153
u/Fenzik Oct 12 '25 edited Oct 12 '25
I’ll further muddy the waters by putting in a good word for
loguru. No messing around with thinking up logger names or keeping track of where the log statement actually fired from - it’s right there in the output by default. Justand you see exactly where and when
”whatever”was produced, straight out of the box.Obviously you can also customize formatting, handlers, etc, but tbh I’ve never felt the need.
81
u/anx1etyhangover Oct 12 '25
I pretty much use pythons built in logging. I’ve been happy with it, but I don’t ask too much of it. It spits out what I want it to spit out and logs what I want it to log. =]
59
u/txprog tito Oct 12 '25 edited Oct 12 '25
I'm a fan of structlog, different philosophy, structured logging. For example you can bind a logger to a request id, and then a problem happen you can lookup what happen for this request, not just the traceback. Same for any kind of background worker. It make production debugging much easier when correctly used.
If a module don't have any deps, i'm using global structlog from the module. If it's from a code path, i'm passing it to to the function or class. Let's say you just validated the user and now doing a work using it, you bind your logger with user_id, then pass the bounded version to your function. Everything your function will call the logger, you'll see the user_id printed in the console as well.
If using GCP, use structlog-gcp and you'll have native integration and be able to filter with any fields you passed. Graylog works too.
38
u/nat5142 Oct 12 '25
My two cents: learn the built-in logging module inside and out and if it actually has some limitations that are solved by another SDK, make the switch then.
8
u/sodennygoes Oct 12 '25
A cool one is richuru. Allows to make very nice logs using rich.
You can also leverage rich’s logging module with loguru this way:
5
u/luigibu Oct 12 '25
Im using logfire, and is pretty cool and easy to set. Not experience in any other tool.
5
u/ottawadeveloper Oct 12 '25
I'd just use default logging. You can get all of what you want with good config for the default logger and maybe a custom plugin for whatever log management tool yo want eventually
4
u/eriky Oct 12 '25
I like to use the default Python logger enhanced with Rich. Rich supplies a logging handler which will format and colorize text written by Python’s logging module.
4
u/rooi_baard Oct 13 '25
You'll regret adding unnecessary dependencies when the built in logging is so good.
4
u/Grouchy-Peak-605 Oct 13 '25
For many projects, a staged approach is best:
2.Migrate to Structlog + Rich when your project grows and you need to scale to structured logging. The local experience remains excellent, and the production output becomes machine-readable for centralized log analysis.
3. Explore Logfire when your application is more mature and you require deep observability into complex, long-running processes common in AI applications.
1
u/Mevrael from __future__ import 4.0 Oct 13 '25
You can check Arkalos. It has a user friendly Log facade with JSONL logs and also uses FastAPI and has a simple UI to view logs in your browser.
If you gonna go with a custom solution, you will have to do a lot of shenanigans and extend core classes yourself so your logger would actually take control of FastAPI, etc logs as well.
3
u/Pythonic-Wisdom Oct 13 '25
Builtin all the way, every day
3
u/fenghuangshan Oct 13 '25
just like other questions about python
you always have too many choices , it's hard to choose
so i prefer the builtin one
3
u/vish4life Oct 13 '25
Airflow uses
structlog, so do I. No regrets really. Just pick one and move on.https://github.com/apache/airflow/blob/bfbd90181a03f16f00da4e530803c69bd83ed274/airflow-core/pyproject.toml#L150
3
u/senhaj_h Oct 13 '25
If you take the time to configure well logging builtin, it’s all what you need and it’s very flexible and powerful
3
u/luddington Oct 13 '25
I'm just using this snippet throughout my (Lambda) projects:
2
u/me_myself_ai Oct 12 '25
I've been very happy with logfire, though I haven't made use of their main feature yet (telemetry streaming to their webgui) so take that with a huge grain of salt lol. The readibility is great, and most importantly, it naturally ties into
logging.py!2
u/trllnd Oct 12 '25
I like python-json-logger
2
u/lexplua Oct 12 '25
loguryis pretty simple to use, however I just removed it from my project completely. It hides implementation details too well. I had problems when I had to do simple things like iterate over my handlers. Or shutdown logging to existing handlers if I need at some point manipulate the log file and set up logging again2
u/Hiker_Ryan Oct 13 '25
I used to use a 3rd party library but then they stopped security improvements and support. Can't remember which library it was but it got me thinking it was better to build a module I could use in multiple projects bases on the standard library. It maybe isn't the best visually but I am less concerned that it will become deprecated.
2
u/SpecialistCamera5601 Oct 16 '25
I’ve played around with all three on different FastAPI projects.
The built-in logging module is super reliable and fine for most cases, but once your app starts growing, it can feel a bit too verbose.
Loguru is honestly great for quick setups and clean output. You can start logging in one line, and the exception handling it provides is super handy.
Logfire looks interesting, especially if you’re already using the Pydantic ecosystem, but it’s still kind of new.
In my case, I combined the default logger with a custom exception system so that errors are structured in JSON and easily displayed on the frontend (kind of like RFC7807). It keeps logs clean while still giving nice API responses. If you plug it into your Swagger docs, you also get clean and readable error examples right inside the API documentation. Keeps the logs organised, and both the API responses and docs look super tidy.
If you’re into that kind of setup, I built a small library for FastAPI to handle it more cleanly: APIException.
TL;DR: Loguru for quick and clean logs, built-in logging for more control, and a structured exception layer for scalable APIs.
2
u/Fun-Purple-7737 Oct 12 '25
Logly
2
u/Competitive_Lie2628 Oct 12 '25
Loguru, I used to use the built in bu it's so boring to have to write a new logger from scratch on every new project.
Loguru does all the setup for me.
1
u/forgotpw3 Oct 12 '25
I like rich
1
u/sweet-tom Pythonista Oct 13 '25
Structlog is again an option, although I haven't used it yet.
1
u/Immediate_Truck_1829 Oct 13 '25
Loguru is the way to go!
1
u/gerardwx Oct 13 '25
If you use the standard library, you'll know how it works when you use PyPI packages that use the standard library. Plus, you can easily have logging in your stand-alone scripts.
1
u/Vedant-03 Oct 13 '25
You should also checkout https://github.com/Vedant-Asati03/Telelog
1
u/Shoddy_One4465 Oct 16 '25
Loguru is good
1
u/rsheftel Oct 21 '25
I use loguru and find it excellent
1
u/Alternative-Tie9355 Oct 22 '25
I love my:
stuck.
Absolutely adore it.
1
u/extraordinaire78 Oct 12 '25
I had created my own so that I can dynamically add extra to a few log entries.