structlog
Structured Logging for Python
Decision gist · record as of 2026-08-14
Yes. structlog is a mature, actively maintained library with no security issues, minimal dependencies, and permissive licensing. It's well-suited for production use if you want structured, queryable logs and are willing to adopt its dictionary-based paradigm. Install it if your application needs JSON or logfmt output, or if you want to add rich context to logs without string formatting.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later; Python 3.8 and 3.9 support have been removed in version 26.1.0.
- Low install friction with a single runtime dependency (typing-extensions).
- Active maintenance since 2013 with a recent release 69 days ago; actively developed with 4914 GitHub stars.
License · maintenance · safety
MIT OR Apache-2.0 (permissive) — Dual-licensed under MIT or Apache-2.0 (permissive), so you can choose either license for your use case with no restrictions on commercial or proprietary applications.
last release 2026-06-06 (69 days) · last repo commit 2026-08-06 · 4,914 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 113,620,670 downloads/mo, #314 on PyPI
Alternatives
Verify before relying
pip install structlog
import structlog
log = structlog.get_logger()
log.info("event", user_id="user", session="session")- Whether the standard library logging integration requires additional setup beyond the basic import.
- Performance characteristics compared to the standard library logging module in high-throughput scenarios.
- Whether all output formatters (JSON, logfmt, console) are equally mature or if some are newer/less tested.
What it is and what it does
structlog is a structured logging library that treats logs as dictionaries rather than formatted strings, letting you emit rich, queryable log events. It has been used in production since 2013 and supports modern Python features like asyncio, context variables, and type hints. You can choose to let structlog handle output directly or forward events to the standard library's logging module, giving you flexibility in how logs are processed and where they go.
The library comes with built-in formatters for JSON, logfmt, and pretty console output, and its processor-based architecture means you can add custom logic (like adding callsite information, thread names, or qualified module names) without modifying your logging calls. It has a single runtime dependency on typing-extensions and is actively maintained with no known security vulnerabilities.
Use it for
- Emit JSON logs in containerized applications for aggregation into centralized logging systems.
- Add structured context to all logs within an async request handler using bound loggers.
- Replace standard library logging with structlog while keeping the same logger interface via stdlib integration.
- Debug production issues by querying queryable log fields instead of parsing unstructured text.
- Log exceptions with rich formatting and optional monochrome output for terminals without color support.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
structlog is a mature, actively maintained library with no security issues, minimal dependencies, and permissive licensing. It's well-suited for production use if you want structured, queryable logs and are willing to adopt its dictionary-based paradigm. Install it if your application needs JSON or logfmt output, or if you want to add rich context to logs without string formatting.
Install
structlog on PyPI
Before you install
Low install friction with a single runtime dependency (typing-extensions). Active maintenance since 2013 with a recent release 69 days ago; actively developed with 4914 GitHub stars.
Requires Python 3.10 or later; Python 3.8 and 3.9 support have been removed in version 26.1.0.
License in practice
Dual-licensed under MIT or Apache-2.0 (permissive), so you can choose either license for your use case with no restrictions on commercial or proprietary applications.
Quickstart
pip install structlog
import structlog
log = structlog.get_logger()
log.info("event", user_id="user", session="session")
Verify before relying
- Whether the standard library logging integration requires additional setup beyond the basic import.
- Performance characteristics compared to the standard library logging module in high-throughput scenarios.
- Whether all output formatters (JSON, logfmt, console) are equally mature or if some are newer/less tested.
Package facts
| License | MIT OR Apache-2.0 permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagetyping-extensions |
| Maintenance | Actively maintained 69 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 113,620,670 / month, #314 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableLicense :: OSI Approved :: Apache Software LicenseLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Topic :: System :: LoggingTyping :: Typed |
Evidence: structlog-26.1.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “bound logger”
- structlogstructlog is a structured logging library that lets you emit logs as…
- weakrefmethodProvides a WeakMethod class for storing bound methods using weak…
- logging-treeVisualizes the hierarchy of loggers, handlers, and filters in…
Give your agent the search over MCP, or paste the wish link into any chat.
More Logging packages
Wraps any iterable to display a real-time progress bar in the terminal or Jupyter notebook, showing iteration count, elapsed time, and estimated time remaining.
Formats Python logging output as JSON, making logs machine-readable for parsing and ingestion into log aggregation tools.
Install it if you need JSON-formatted logs for aggregation or centralized monitoring.
Loguru provides a pre-configured logger that replaces Python's standard logging with a simpler, zero-boilerplate interface for writing log messages to stderr, files, or custom handlers.
Install it if you want logging to feel natural but with the power, structure that production code needs.
Adds colored output to Python's standard logging module using ANSI escape sequences, with automatic fallback support for Windows terminals.
However, it is abandoned and receives no maintenance, so it will not adapt to future Python changes or platform updates.
wandb is a machine learning experiment tracking and visualization platform that logs metrics, hyperparameters, datasets, and models to a centralized dashboard for monitoring and comparing training runs.
Install it if you need centralized experiment tracking, comparison, and visualization for machine learning projects; skip it if you prefer local-only logging or have…
progressbar2 renders text-based progress bars in the terminal, handling custom widgets, concurrent bars, unknown-length progress, and clean output around logs and prints.
See also django-structlog · macwinnie-enhanced-logging · structlog-sentry · logfmter · structlog-pretty · pytest-structlog · opentelemetry-instrumentation-structlog · Twiggy · structlog-gcp · Logbook