Loguru
Point Loguru at Logfire and your existing Loguru output shows up in Logfire as structured logs (individual timestamped records of something that happened), next to the traces (the full journey of one request through your app) from the rest of your code, with no change to how you write log calls.
- Each Loguru log message
- Its severity level (info, warning, error, and so on)
- Its timestamp
- Any structured fields you attach to the record
You’ll need a Logfire project. Open Add data in your project (top navigation) and follow the
setup for your language: it signs your machine in with logfire auth (a browser sign-in, no token
to copy) and, for production or other languages, creates a write token (the credential your app
uses to send data). New to Logfire? Start with Getting Started.
Install logfire:
pip install logfire
uv add logfire
conda install -c conda-forge logfire
This works with your existing loguru package: nothing extra to install. If you don’t have it yet,
run pip install loguru in your terminal.
Call logfire.configure() to connect to your project, then add
logfire.loguru_handler() as a Loguru sink so every record Loguru
emits is also sent to Logfire.
from loguru import logger
import logfire
logfire.configure()
logger.configure(handlers=[logfire.loguru_handler()])
logger.info('Hello, {name}!', name='World')
Run your program, then open the Live view in the Logfire web app. Within a few seconds you’ll see your message as a record.
Not seeing your logs in Logfire? Check that logfire.configure() ran first, your write token is set,
and the Logfire handler is attached to Loguru via logger.configure(handlers=[...]).
- API reference:
logfire.loguru_handler()