Repolode
Delgan

Delgan/loguru

Python logging library that replaces the standard logging setup with a single logger, file rotation, colored output and structured logs.

Stars
24,153
Forks
828
Open issues
261
Last commit
6 days ago

What is it?

Loguru is a Python logging library aimed at removing the boilerplate of the standard logging module. It exposes one pre-configured logger that writes to stderr out of the box, so you can start logging with a single import. Additional sinks, formats, filters and levels are all set through one add() function.

File logging covers rotation by size, time or age, retention cleanup and compression on close. The library also offers brace-style string formatting, colored output, exception stack traces that include variable values, and thread-safe and enqueued multiprocess-safe sinks. Context can be attached with bind() or contextualize(), and messages can be serialized to JSON.

Loguru includes compatibility helpers for standard logging, letting you route existing logging.Handler objects into Loguru sinks or forward Loguru messages back to the standard module. It supports Python 3.5 and later as well as PyPy.

Key features

  • 01Preconfigured logger that works without setup code
  • 02Single add() function to manage sinks, formats, filters and levels
  • 03File rotation, retention and compression options
  • 04Colored terminal output and full exception traces with variable values
  • 05Thread-safe sinks and queue-based multiprocess-safe logging
  • 06Bridges to and from Python's standard logging module

Use cases

  • Adding logging to a Python script without writing logger configuration
  • Writing rotated, compressed log files for long-running services
  • Capturing exceptions raised in threads so they appear in logs
  • Keeping a Python library silent by default while letting applications enable its logs

Quick start

  1. 1

    Install loguru from PyPI

    pip install loguru
  2. 2

    Import the ready-to-use logger and log a message

In collections

Topics

FAQ

What is loguru?
Python logging library that replaces the standard logging setup with a single logger, file rotation, colored output and structured logs. Loguru is a Python logging library aimed at removing the boilerplate of the standard logging module. It exposes one pre-configured logger that writes to stderr out of the box, so you can start logging with a single import. Additional sinks, formats, filters and levels are all set through one add() function.
Is loguru free to use? What license does it have?
loguru is open source under the MIT license. Check the license terms before using it in commercial products.
Is loguru still maintained?
Actively maintained. The last commit to loguru was on Oct 18, 2026.
What can I use loguru for?
Adding logging to a Python script without writing logger configuration Writing rotated, compressed log files for long-running services Capturing exceptions raised in threads so they appear in logs Keeping a Python library silent by default while letting applications enable its logs
How do I install loguru?
Install loguru from PyPI: pip install loguru Import the ready-to-use logger and log a message
Where can I get loguru?
The source code and installation instructions are on GitHub: https://github.com/Delgan/loguru

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects