JSON-log-formatter
JSON log formatter
What it is and what it does
json-log-formatter wraps Python's standard logging module to emit structured JSON records instead of plain text. It integrates with the logging handler pipeline, converting log messages and extra fields into JSON objects written to files or streams. The library provides three formatter classes: JSONFormatter for minimal output, VerboseJSONFormatter to include standard LogRecord attributes (filename, level, thread info, etc.), and FlatJSONFormatter to stringify complex objects. It supports custom formatters by subclassing and allows swapping the underlying JSON library.
The package is designed for environments where logs feed into aggregation systems like Logstash or cloud logging platforms that parse and index JSON. It works with Django's logging configuration and requires no external dependencies beyond Python 3.9+, making it lightweight to add to existing projects.
Use it for:
- Integrate application logs with Logstash or Elasticsearch for centralized log analysis and monitoring.
- Add structured metadata (user IDs, request IDs, custom fields) to logs for easier filtering and debugging in production.
- Replace plain-text logging with JSON to enable automated parsing and alerting in log aggregation pipelines.
- Configure Django applications to emit JSON logs for cloud logging services that expect structured input.
- Extend logging with custom fields and transformations by subclassing JSONFormatter for domain-specific requirements.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Formats Python logging records as JSON, enabling structured log output suitable for ingestion by log aggregation systems like Logstash.
Yes. The package is lightweight, dependency-free, actively maintained, and solves a concrete problem—structured JSON logging is now standard practice for production systems. Install it if you're already using Python's logging module and need JSON output for log aggregation or cloud platforms.
Install
json-log-formatter on PyPI
pip
pip install json-log-formatteruv
uv add json-log-formatterpoetry
poetry add json-log-formatterInstalling JSON-log-formatter
Before you install
Low install friction—pure Python wheel with no runtime dependencies. Actively maintained as of June 2026 with recent release history.
License in practice
MIT license permits unrestricted use, modification, and distribution in commercial and private projects.
Quickstart
import logging
import json_log_formatter
formatter = json_log_formatter.JSONFormatter()
json_handler = logging.FileHandler(filename='/var/log/my-log.json')
json_handler.setFormatter(formatter)
logger = logging.getLogger('my_json')
logger.addHandler(json_handler)
logger.setLevel(logging.INFO)
logger.info('Sign up', extra={'referral_code': '52d6ce'})
Requires Python 3.9 or later.
Verify before relying
- Performance characteristics when logging at high volume or with large extra fields.
- Compatibility with alternative JSON libraries (ujson, simplejson) beyond the documented examples.
- Whether custom formatters can be subclassed without breaking changes across minor versions.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 67 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,134,411/month — #2,734 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: json_log_formatter-1.2.1-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
logstash_formatterFormats Python logging output as JSON objects…
permissive · top 15,000 on PyPI
mo-logsProvides structured JSON logging with…
copyleft · top 15,000 on PyPI
python-json-loggerFormats Python logging output as JSON, making…
permissive · top 1,000 on PyPI
jsonformatterFormats Python logging output as JSON, enabling…
permissive · top 15,000 on PyPI
logging-jsonFormats Python logging records as JSON output,…
permissive · top 15,000 on PyPI
logzerologzero provides pre-configured Python logging…
permissive · top 5,000 on PyPI
python-logstashSends Python log records to Logstash over UDP…
permissive · top 15,000 on PyPI
json-loggingConfigures Python's standard logging module to…
permissive · top 5,000 on PyPI
logdnaIntegrates Python's standard logging framework…
permissive · top 15,000 on PyPI
daiquiriDaiquiri simplifies Python logging…
permissive · top 15,000 on PyPI