Pain-free logging

Logging for the lazy: Python library makes logging simple

Sarah Schlothauer
© Shutterstock / birdyyang

Why do you have to go and make things so complicated? Keep it simple! For Python users, Loguru provides an easier, pain-free logging experience. Let’s explore this library and see how it can help even the laziest of us.

Sometimes the best solution is to keep things simple. One library holds true to this helpful mantra. Loguru is a Python library for logging and its description on GitHub reads “Python logging made (stupidly) simple“. Designed by Delgan on GitHub, this project has already received its fair share of stars and forks.

How simple and pain-free? Let’s take a lesson from the guru and see.

The guru is in

From the project’s GitHub repo:

Did you ever feel lazy about configuring a logger and used print() instead?… I did, yet logging is fundamental to every application and eases the process of debugging. Using Loguru you have no excuse not to use logging from the start, this is as simple as from loguru import logger.

Also, this library is intended to make Python logging less painful by adding a bunch of useful functionalities that solve caveats of the standard loggers. Using logs in your application should be an automatism, Loguru tries to make it both pleasant and powerful.

The concept of “automate everything!” is one of the great tenants about this library. It streamlines Python logging.

SEE ALSO: Finding your “forever” programming language: Is it still possible in today’s rapidly changing technology landscape?

First of all, a key concept in keeping a library simple are ready to use, out of the box features. Since Loguru comes pre-configured, it’s like unwrapping a toy on your birthday with the batteries already included!

Out of the box, Loguru outputs to stderr .



Python logging made simple

While not an exhaustive list, here are some other features of Loguru:

  • Colors! Add color markups to your log. (Based off of python-ansimarksup)
  • Customize levels. Add new levels with the level() function.
  • The add() function is multi-purpose. It is used for adding a handler, setting up log formatting, filtering messages and setting levels.
  • Bloat-free, better datetime handling: Less bloat compared to standard logging
  • Suitable for scripts and libraries: Use Loguru from inside a library
  • Compatible with standard logging
  • Customizable defaults
  • Alert notifications: When paired with the notifiers library (on GitHub here, must be installed separately) you can receive e-mail notifications when your program fails, or any other kinds of error alerts you choose.
  • Identify problems in your code with fully descriptive exceptions
  • Asynchronous, Thread-safe, Multiprocess-safe

SEE ALSO: Year of the Snake: TIOBE crowns Python as the programming language of 2018!

Setting up & future plans

Is this simple logging library for you? Read this thread on the r/Python subreddit for reactions, reviews, and feedback.

Installation is done through pip install loguru.

View the Loguru change log here. The most recent Python version to receive support is Python 3.5 (and support for PyPy).

This update arrived on December 16, 2018. Since the developer has added recent updates, can we assume that the future holds more goodies and support?

On GitHub, the developer alludes to an “upcoming release” where “Loguru’s critical functions will be implemented in C for maximum speed”. So, a future update will hopefully make Loguru faster than built-in logging! In the changelog, we see a teaser regarding an unreleased feature: “Fix race condition permitting to write on a stopped handler”.

Sarah Schlothauer

Sarah Schlothauer

All Posts by Sarah Schlothauer

Sarah Schlothauer is the editor for She received her Bachelor's degree from Monmouth University, West Long Branch, New Jersey. She currently lives in Frankfurt, Germany with her husband and cat where she enjoys reading, writing, and medieval reenactment. She is also the editor for Conditio Humana, an online magazine about ethics, AI, and technology.

Inline Feedbacks
View all comments