skillfed

JSON-log-formatter

JSON log formatter

json-log-formatter v1.2.1 3.1M downloads/30d#2,734 on PyPI118
Permissive license MIT Active released

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-formatter

uv

uv add json-log-formatter

poetry

poetry add json-log-formatter

Installing 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

Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Topic :: Software Development :: Libraries :: Python Modules

Tags

json log formatterstructured logging pythonlogstash integrationjson logging handlerlog aggregation formattingstructured log outputpython json logs
loggingstructured-logsjson-output

More Python Modules packages