A Python logging library that simplifies configuration with a single logger, colorful output, and powerful features like rotation and exception catching.
Loguru is a Python logging library that makes logging simple and enjoyable by providing a pre-configured logger with minimal setup. It solves the complexity and boilerplate of Python's standard logging module with features like automatic file rotation, colorful output, and detailed exception traces. The library aims to encourage developers to use proper logging from the start of their projects.
Python developers at all levels who want a hassle-free logging solution for scripts, applications, or libraries without dealing with the standard logging module's configuration complexity.
Developers choose Loguru because it eliminates logging boilerplate with a single import, offers powerful features like file rotation and structured logging out of the box, and provides beautiful colored output while maintaining full compatibility with the standard logging ecosystem.
Python logging made (stupidly) simple
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Just import 'logger' to start logging with colored output to stderr, eliminating boilerplate and encouraging logging from day one, as shown in the README's initial example.
The add() function supports rotation by size, time, or age, retention policies, and compression with simple parameters, making log file handling effortless without external tools.
The catch() decorator logs exceptions with full stack traces and variable values (when diagnose=True), useful for debugging in threads or main programs, as demonstrated in the README.
Supports JSON serialization and context binding via bind(), allowing for easier log parsing and analysis while maintaining compatibility with standard logging handlers.
Loguru's design centers on a single global logger, which can be restrictive for complex applications needing hierarchical or module-specific logging configurations.
The default diagnose=True setting in backtraces can leak sensitive variable data in production, requiring manual adjustment to avoid security issues, as noted in the README's caution.
Advanced functionalities like notifications rely on third-party libraries such as apprise or logprise, adding complexity and potential dependency management overhead.