Python logging libraries

Updated Nov 2026

Python logging libraries record events from a running program, such as requests, warnings, and errors. Most of them extend the standard logging module that ships with Python. These libraries give developers the records they search when a service fails in production.

Popularity

Rich has the most monthly downloads in this comparison, at 579.9M, a count that covers the whole Rich package rather than its logging handler alone.

LibraryMonthly downloadsStarsLast releaseLicense
Rich
579.9M
57.8KApr 2026MIT
OpenTelemetry SDK
345.7M
Not on GitHubOct 2026Apache-2.0
Sentry SDK
157.9M
Not on GitHubNov 2026MIT
structlog
128.0M
5.0KJun 2026MIT OR Apache-2.0
Python JSON Logger
106.9M
Not on GitHubAug 2026BSD-2-Clause
Loguru
85.4M
24.2KNov 2026MIT
colorlog
48.6M
Not on GitHubJul 2026MIT
coloredlogs
40.2M
Not on GitHubJun 2021MIT
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Features compared

LibraryLocal JSON log renderingColored terminal loggingStdlib Formatter class
RichUnsupportedBuilt-inUnsupported
OpenTelemetry SDKBuilt-inUnsupportedUnsupported
Sentry SDKUnsupportedUnsupportedUnsupported
structlogBuilt-inBuilt-inBuilt-in
Python JSON LoggerBuilt-inUnsupportedBuilt-in
LoguruBuilt-inBuilt-inUnsupported
colorlogUnsupportedBuilt-inBuilt-in
coloredlogsUnsupportedBuilt-inBuilt-in
Built-inNot supported

Libraries and code examples

Rich renders formatted text, tables, progress bars, and syntax highlighting in the terminal, and its RichHandler class is a handler for the standard logging module. The handler formats and colorizes each record that logging emits. Passing it in the handlers list of logging.basicConfig changes the output without touching any log call. With rich_tracebacks set, exceptions go through Rich's traceback formatter, which shows more context than the built-in one, and tracebacks_suppress hides frames from frameworks such as Click.

Downloads / mo
579.9M
Stars
57.8K
Last release
15.0.0
License
MIT

Strengths

  • Keeps standard logging APIs. Attach RichHandler to the standard logging configuration.
  • Formats detailed exception tracebacks. Enable rich_tracebacks to render exceptions through Rich’s traceback formatter.

Limitations

  • Markup is disabled by default. Enable markup only when log messages intentionally contain Rich markup.

Quickstart

From logging.html
$ python3.13 -m pip install rich==15.0.0
import logging
from rich.logging import RichHandler

FORMAT = "%(message)s"
logging.basicConfig(
    level="NOTSET", format=FORMAT, datefmt="[%X]", handlers=[RichHandler()]
)

log = logging.getLogger("rich")
log.info("Hello, World!")

Rich examples

From open-source projects on GitHub

OpenTelemetry SDK

The OpenTelemetry SDK is the Python implementation of OpenTelemetry for traces, metrics, and logs. For logs, LoggingHandler attaches to the standard logging module and writes each record in OTLP, the OpenTelemetry protocol. Processors such as BatchLogRecordProcessor pass records to an exporter. ConsoleLogRecordExporter prints them for debugging, while sending them to a collector over HTTP or gRPC takes a separate exporter package, such as opentelemetry-exporter-otlp-proto-http.

Downloads / mo
345.7M
Last release
1.45.2
License
Apache-2.0

Strengths

  • Writes OTLP records. LoggingHandler sends standard logging records to a network destination or a file in OTLP format.

Quickstart

From _logs.html
$ python3.13 -m pip install opentelemetry-sdk==1.45.2
from opentelemetry.sdk._logs import LoggerProvider
from opentelemetry.sdk._logs.export import ConsoleLogRecordExporter, SimpleLogRecordProcessor

provider = LoggerProvider()
provider.add_log_record_processor(SimpleLogRecordProcessor(ConsoleLogRecordExporter()))
provider.get_logger("example").emit(body="Hello", severity_text="INFO")
provider.shutdown()

OpenTelemetry SDK examples

From open-source projects on GitHub

The Sentry SDK reports errors and logs from a Python application to Sentry, a hosted error tracking service. After sentry_sdk.init runs with a project DSN, the sentry_sdk.logger namespace sends structured messages whose placeholders, such as {user_id}, become searchable attributes. The LoggingIntegration captures records from the standard logging module as Sentry logs and breadcrumbs. Records at error level and above can also become error events through the event_level option.

Downloads / mo
157.9M
Last release
2.75.0
License
MIT

Strengths

  • Searchable by attribute. Logs appear beside related errors and can be searched by text or by individual attributes.

Limitations

  • Recent SDK required. Logs need Sentry Python SDK 2.35.0 or later.

Quickstart

From index.html
$ python3.13 -m pip install sentry-sdk==2.75.0
import sentry_sdk

sentry_sdk.init(dsn="https://<key>@o<orgId>.ingest.sentry.io/<projectId>", enable_logs=True)
sentry_sdk.logger.info("Hello")
sentry_sdk.flush()

Sentry SDK examples

From open-source projects on GitHub

structlog builds each log entry as a dictionary of key and value pairs, called an event. A configured chain of processors adds fields such as the level and a timestamp, then a renderer turns the event into JSON, logfmt, or colored console text. structlog.get_logger works with no setup and prints to standard output. Values bound once with bind or through context variables appear on every later event. The final output can also go through the standard logging module.

Downloads / mo
128.0M
Stars
5.0K
Last release
26.1.0
License
MIT OR Apache-2.0

Strengths

  • Processes structured event dictionaries. Choose processors and a renderer for the desired event output.
  • Binds request-local log context. Merge context variables into events and bind request fields once.

Limitations

  • Request context needs explicit reset. Clear context variables at request entry before binding the next request’s fields.

Quickstart

From getting-started.html
$ python3.13 -m pip install structlog==26.1.0
import structlog
log = structlog.get_logger()
log.info("hello, %s!", "world", key="value!", more_than_strings=[1, 2, 3])

structlog examples

From open-source projects on GitHub

Python JSON Logger

Python JSON Logger supplies formatter classes for the standard logging module that encode each record as JSON. JsonFormatter attaches to any existing handler through setFormatter. The fmt argument sets the fields and accepts the same format styles as logging. Messages can also be dictionaries, and values passed through extra become fields of the JSON object.

Downloads / mo
106.9M
Last release
4.2.0
License
BSD-2-Clause

Strengths

  • Plugs into existing handlers. The formatter attaches to a standard logging handler, and existing log calls stay unchanged.

Quickstart

From quickstart.md
$ python3.13 -m pip install python-json-logger==4.2.0
import logging
from pythonjsonlogger.json import JsonFormatter

logger = logging.getLogger()

logHandler = logging.StreamHandler()
formatter = JsonFormatter()
logHandler.setFormatter(formatter)
logger.addHandler(logHandler)

logger.warning("Hello")

Python JSON Logger examples

From open-source projects on GitHub

Loguru replaces the setup of the standard logging module with one preconfigured logger that writes to standard error on import. The add method registers each destination, called a sink, which can be a file path, a function, a file object, or a standard logging handler. File sinks take rotation, retention, and compression settings. With serialize set, each record reaches the sink as a JSON string, and bind attaches fields to later messages.

Downloads / mo
85.4M
Stars
24.2K
Last release
0.8.0
License
MIT

Strengths

  • Manages rotating log sinks. Configure file rotation, retention, and compression on the logger.
  • Serializes structured log events. Enable serialize to send JSON-formatted records to the configured sink.

Limitations

  • Diagnostics include variable values. Set diagnose=False when production tracebacks must omit local variable values.

Quickstart

From README.md
$ python3.13 -m pip install loguru==0.8.0
from loguru import logger

logger.debug("That's it, beautiful and simple logging!")

Loguru examples

From open-source projects on GitHub

colorlog adds color to the output of the standard logging module. Its ColoredFormatter class extends logging.Formatter and replaces the formatter on any existing handler. A log_colors mapping assigns a color to each level name, and secondary_log_colors colors other parts of the format string. On Windows, colorama installs as a dependency so that the colors display.

Downloads / mo
48.6M
Last release
6.12.0
License
MIT

Strengths

  • Extends logging.Formatter. ColoredFormatter replaces the formatter on any standard logging handler.

Limitations

  • Color off outside terminals. Colors turn off on output that is not a terminal unless force_color is set.

Quickstart

From README.md
$ python3.13 -m pip install colorlog==6.12.0
import logging
import colorlog

handler = colorlog.StreamHandler()
handler.setFormatter(colorlog.ColoredFormatter("%(log_color)s%(levelname)s:%(name)s:%(message)s"))
logger = colorlog.getLogger("example")
logger.addHandler(handler)
logger.setLevel(logging.INFO)
logger.info("Hello")

colorlog examples

From open-source projects on GitHub

coloredlogs colors terminal output from the standard logging module with ANSI escape sequences. One call to coloredlogs.install adds a colored handler to the root logger. The ColoredFormatter class inherits from logging.Formatter for setups that attach their own handlers. On Windows, the package tries native ANSI support first and falls back on colorama when it is installed.

Downloads / mo
40.2M
Last release
15.0.1
License
MIT

Strengths

  • One-call setup. coloredlogs.install adds a colored handler to the root logger, which also colors messages from other libraries.

Quickstart

From api.html
$ python3.13 -m pip install coloredlogs==15.0.1
import coloredlogs, logging

coloredlogs.install(level="DEBUG")
logger = logging.getLogger("some.module.name")
logger.info("this is an informational message")

coloredlogs examples

From open-source projects on GitHub

FAQ

The standard logging module ships with Python, and most libraries here plug into it. Rich, colorlog, and coloredlogs add color, and Python JSON Logger adds JSON, with no change to existing log calls. Loguru and structlog replace the setup with their own logger API.

Loguru provides one preconfigured logger, and its add method registers each output, called a sink, in place of the handlers, formatters, and filters that logging uses. File sinks take rotation, retention, and compression settings directly.

structlog builds each event as a dictionary that passes through a chain of processors, then renders JSON, logfmt, or console output, or hands the event to logging. Loguru keeps a single logger that sends message records to sinks, and writes JSON when a sink sets serialize.

Python JSON Logger adds a JSON formatter to existing logging handlers. structlog renders JSON with JSONRenderer, and Loguru writes JSON when a sink sets serialize.

Pass RichHandler() in the handlers list of logging.basicConfig. Setting rich_tracebacks on the handler formats exceptions with Rich's traceback renderer.

The standard library includes RotatingFileHandler for size and TimedRotatingFileHandler for time. Loguru takes a rotation setting on each file sink.

For coding agents

Found your logging library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official