loguru
Python logging that doesn't make you want to cry — structured, colorful, zero-config, with automatic exception tracebacks.
Python's built-in logging module requires boilerplate setup (handlers, formatters, loggers) just to print a colored timestamp. It's powerful but the API is from 2003 and shows its age.
Loguru has a single pre-configured logger object. You import it and call logger.info(). Under the hood it handles formatting, colors, log rotation, JSON output, and exception capture. Add sinks (files, services) with logger.add().
Replace print statements with proper logging
from loguru import logger
logger.debug('Debugging value: {}', some_var)
logger.info('Server started on port {}', 8000)
logger.warning('Cache miss — fetching from DB')
logger.error('Failed to connect: {}', exc)
logger.success('All 42 records processed')
logger.add(
'logs/app.log',
level='INFO',
rotation='10 MB', # new file when this size is hit
retention='7 days', # delete old files
compression='zip', # compress rotated files
)Use it when
Any Python application that needs logging — scripts, APIs, workers. Especially good for: colorized console output during development, structured JSON logs for production, automatic exception tracing.
Skip it when
If your team's infrastructure is already built around stdlib logging and you can't change it easily — loguru can interop but it adds complexity.
Ready to explore the full API?
See every class, function, and relationship in an interactive graph.