Loguru vs logging: Which Python Logger to Use

Loguru vs the standard library logging module compared: setup, formatting, rotation, exceptions, library use and how to bridge the two, with tested code.

Use Loguru for applications and scripts where you want logging working in two lines, and the standard logging module when you write a library or must fit the wider ecosystem. They also work together, so it is not an all-or-nothing choice.

The examples were run with Loguru 0.8.0, released on 11 November 2026, on Python 3.14.10. An earlier pass used 0.7.3, the previous release, and what changed is listed under “Check the version” below.

At a glance

logging (standard library) Loguru
Install Built in pip install loguru
With no configuration Warnings and above only, as WARNING:root:message A ready logger printing from DEBUG upwards to stderr
Setup model Loggers, handlers, formatters, filters One logger and one add() function
Message arguments %s style arguments, formatted only if emitted {} style, equivalent to str.format()
File rotation RotatingFileHandler, TimedRotatingFileHandler rotation=, retention= and compression= in add()
Exceptions log.exception(...) inside an except block @logger.catch, with a detailed traceback
Structured context extra= and filters logger.bind(user="ada")

The standard logging module

import logging

logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s %(levelname)s %(name)s: %(message)s",
)
log = logging.getLogger(__name__)

log.info("Starting")
try:
    1 / 0
except ZeroDivisionError:
    log.exception("Calculation failed")

It is in the standard library, so every framework and package already uses it. The cost is concepts: a hierarchy of named loggers, handlers that decide where output goes, and formatters that decide how it looks. Without any configuration the root logger prints only warnings and above, as WARNING:root:warning message; logging.info printed nothing.

Passing values as arguments, log.info("info with %s", obj), defers the formatting. In a test, an object’s __str__ was not called for a debug message below the logger’s level, but it was always called when written as an f-string. The documentation’s rotation classes behave as expected: a RotatingFileHandler with maxBytes=1000, backupCount=2 produced std.log, std.log.1 and std.log.2.

Loguru

import sys
from loguru import logger

logger.remove()
logger.add(sys.stdout, format="{level} | {message}")
logger.add("app.log", rotation="10 MB", retention="7 days")

logger.info("Starting")

@logger.catch
def run():
    return 1 / 0

run()   # logs the error and traceback, returns None

The README’s central idea is that there is one and only one logger, pre-configured to write to stderr. add() registers a sink, which can be a stream, a file path or a function, and it takes the format, filter and level; remove() takes a handler off again. @logger.catch logs the exception with a traceback that shows the values of variables, and the call returned None instead of raising.

A caution from the README: diagnose=True, which prints those variable values, is the default and may leak sensitive data in production, so turn it off in add() there.

Rotation and retention strings from the README all parsed without error: rotation="12:00", rotation="1 week", retention="10 days" and compression="zip". With rotation="1 KB" and retention=2, sixty short lines produced lg.log and files named like lg.2026-11-04_12-31-44_367972.log, so rotated files are named by timestamp where the standard library numbers them.

Messages use braces: logger.info("We discovered {} is the answer to {question}", 42, question="everything"). A message below every sink’s level skipped formatting in the same way as the standard library. logger.bind(user="ada") adds context, which a sink can print as {extra[user]}. See what Loguru is for the full tour, or the Loguru resource page.

Check the version

Loguru 0.8.0 came out on 11 November 2026, the first release since 0.7.3 (6 December 2024), so older tutorials describe older behaviour. From its changelog, with what was seen when each was run:

  • Template strings work as log messages. logger.info(t"hello {name}") printed hello ada on 0.8.0. In an earlier test on 0.7.3 the same call on Python 3.14 printed the raw Template(strings=..., interpolations=...) object.
  • The default format includes the timezone offset. A message in the default format printed as 2026-11-14 09:41:19.300 +00:00 | INFO | __main__:<module>:38 - default format.
  • rotation accepts a list of conditions, any of which triggers a rotation: rotation=["1 KB", "12:00"] was accepted.
  • Colour follows the NO_COLOR and FORCE_COLOR environment variables, and a new logger.reinstall() sets the logger up again in spawned child processes.

Before the release, the project README already described template strings while the changelog listed them as unreleased. Check the changelog against the version you have installed (pip show loguru) before relying on a README example.

Rules of thumb

  • Writing an application or script: either works. Loguru is quicker to set up and nicer to read.
  • Writing a library: the Python logging HOWTO says to use a logger with a unique name, such as logging.getLogger(__name__), not to log to the root logger, and not to add any handler other than NullHandler, because handlers are the application developer’s choice. Loguru’s README describes another route, where the library calls logger.disable("my_library") and the application calls logger.enable("my_library"). The first needs no extra dependency and respects the application’s configuration.
  • Using frameworks that log via logging: their messages go through the standard module whatever you choose, so bridge them if you want one output.

Bridging the two

The README’s InterceptHandler forwards standard library records to Loguru. It worked as shown:

import inspect, logging
from loguru import logger

class InterceptHandler(logging.Handler):
    def emit(self, record: logging.LogRecord) -> None:
        try:
            level = logger.level(record.levelname).name
        except ValueError:
            level = record.levelno
        frame, depth = inspect.currentframe(), 0
        while frame:
            filename = frame.f_code.co_filename
            is_logging = filename == logging.__file__
            is_frozen = "importlib" in filename and "_bootstrap" in filename
            if depth > 0 and not (is_logging or is_frozen):
                break
            frame = frame.f_back
            depth += 1
        logger.opt(depth=depth, exception=record.exc_info).log(level, record.getMessage())

logging.basicConfig(handlers=[InterceptHandler()], level=0, force=True)

After that, logging.getLogger("some.library").warning("from a stdlib logger (%s)", "via intercept") came out of Loguru’s sink with the right module and line. For the reverse direction, the README’s PropagateHandler sends Loguru messages to the standard module.

Web servers

Uvicorn logs to the uvicorn.error and uvicorn.access loggers and Gunicorn to gunicorn.error and gunicorn.access, all standard library loggers. One gotcha: Uvicorn’s default logging configuration (checked in Uvicorn 0.54.0) sets propagate to False for uvicorn.access, so a handler on the root logger, including InterceptHandler, does not see access logs unless you reconfigure that logger. See Gunicorn vs Uvicorn vs Hypercorn for the servers themselves.

Which should you choose?

If you are new to logging, start with logging.basicConfig so you learn the concepts everyone uses. Move to Loguru when you want rotation, structured context or friendlier exceptions without the boilerplate. For how this fits with the rest of the standard library, see the standard library guide.

Frequently Asked Questions

Is Loguru better than the logging module?

Loguru is simpler for applications and scripts: one ready-made logger, file rotation in a single call and detailed exception output. The standard library logging module needs more setup but is built in and is what frameworks and most libraries use, so even a Loguru project still meets it.

Should a library use Loguru?

Both approaches exist. Loguru’s README says it suits libraries when the library calls logger.disable with its own name and the application calls logger.enable. The Python logging HOWTO tells library authors to use a named logger and add only a NullHandler. Using logging avoids an extra dependency and lets the application’s existing configuration apply.

Can Loguru and logging work together?

Yes. Loguru’s README shows an InterceptHandler class that sends standard library log records to Loguru, and a PropagateHandler that sends Loguru messages to standard logging. Install the InterceptHandler with logging.basicConfig(handlers=[InterceptHandler()], level=0, force=True).

How do I rotate log files with Loguru?

Pass rotation and retention to logger.add, for example logger.add(‘app.log’, rotation=‘10 MB’, retention=‘7 days’). The standard library does this with RotatingFileHandler, using maxBytes and backupCount, or TimedRotatingFileHandler.

Why does logging.info print nothing?

The root logger’s default level is WARNING, so with no configuration only warnings and above are printed, in the form WARNING:root:message. Call logging.basicConfig(level=logging.INFO) to see info messages.