--- id: logfmter version: "0.0.12" license: MIT license_treatment: permissive maintenance: active --- # logfmter — A Python package which supports global logfmt formatted logging. License: permissive · Maintenance: active · Downloads: 210.6K/mo ## What it is and what it does Logfmter is a Python logging formatter that converts stdlib logging output into logfmt structured format—a key-value log format designed for both human readability and machine parsing. It integrates as a standard logging.Formatter, so you pass it to a handler and all logs automatically emit as logfmt without touching any existing log statements. The formatter accepts configuration for which fields to include (like log level, timestamp, process name), custom key-to-LogRecord-attribute mappings, default values, and fields to exclude. The package handles both simple log messages and extra dictionaries passed to logging calls, formatting them as space-separated key=value pairs. It supports subclassing for custom value formatting and can template default values using format strings. With no external dependencies and active maintenance, it's designed as a drop-in way to adopt structured logging in existing applications. Use it for: - Adopt structured logging in an existing application without rewriting log statements. - Ensure all third-party library logs conform to a single logfmt format for centralized log aggregation. - Add trace IDs, request IDs, or other context fields to all logs via defaults without modifying each call. - Parse logs programmatically or feed them to log aggregation tools that expect key-value structure. - Customize log field names and values by subclassing to match your organization's logging schema. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Formats Python stdlib logging output as logfmt structured logs without modifying existing log calls, enabling both human and machine-readable output. Yes. Logfmter is a lightweight, dependency-free formatter that solves a real problem—adopting structured logging without refactoring existing code. Active maintenance, permissive license, no known vulnerabilities, and low install friction make it a safe choice. Install if you need logfmt output from stdlib logging. ## Install pip install logfmter uv add logfmter poetry add logfmter ## Installing logfmter Before you install: Low friction: pure Python wheel with no runtime dependencies. Actively maintained with recent releases; last commit 2026-06-05. License in practice: MIT license permits free use, modification, and distribution with minimal restrictions. Quickstart: import logging from logfmter import Logfmter handler = logging.StreamHandler() handler.setFormatter(Logfmter()) logging.basicConfig(handlers=[handler]) logging.error("hello", extra={"alpha": 1}) Requires Python 3.10 or later. Verify before relying: - Performance characteristics when formatting high-volume logs or large extra dictionaries. - Compatibility with async logging frameworks or concurrent logging scenarios. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 210.6K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags logfmt structured logging, stdlib logging formatter, structured log output, logfmt python logging, machine-readable logs, log formatting stdlib, structured-logging, logfmt [View on SkillFed](https://skillfed.io/packages/logfmter) · [View on PyPI](https://pypi.org/project/logfmter/)