logging-json
JSON formatter for python logging
What it is and what it does
logging-json is a formatter for Python's standard logging module that converts log records into JSON output. It sits between your application's logging calls and the output stream, intercepting records and serializing them as structured JSON dictionaries. This is particularly useful when your logs are consumed by centralized log aggregation systems like Splunk or Elasticsearch, which expect structured data rather than plain text.
The formatter handles three main logging patterns: dictionary logging (where you pass a dict directly), string logging (where you pass a message string), and exception logging (where it captures exception type, message, and stack trace). You can add custom fields to every log entry, customize field names, and control timestamp formatting. It integrates seamlessly with Python's standard logging.config.dictConfig, allowing you to configure it via Python dict or YAML file.
Use it for:
- Send application logs to Splunk or Elasticsearch with proper JSON structure for indexing and search.
- Add custom metadata fields (service name, environment, request ID) to every log entry automatically.
- Capture exception details including type, message, and full stack trace in a structured JSON format.
- Replace plain-text logging with structured output for easier parsing and analysis in log aggregation platforms.
- Configure JSON logging via YAML or dictConfig without modifying application code.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Formats Python logging records as JSON output, enabling structured logs suitable for ingestion by log aggregation platforms like Splunk or Elasticsearch.
Yes, if you need structured JSON logging for a log aggregation platform. The package is stable, dependency-free, and straightforward to integrate. Dormant maintenance is acceptable for a focused formatter—the core logging API is unlikely to change. No known vulnerabilities. Install if you're already using Splunk, Elasticsearch, or similar systems; skip if you only need plain-text or Python's default formatting.
Install
logging-json on PyPI
pip
pip install logging-jsonuv
uv add logging-jsonpoetry
poetry add logging-jsonInstalling logging-json
Before you install
Low friction: pure Python wheel with no runtime dependencies. Dormant maintenance (last commit 2025-02-04, 556 days since release) but marked Production/Stable and supports current Python versions through 3.13.
License in practice
MIT License permits unrestricted use, modification, and distribution with minimal obligations—suitable for any project type.
Quickstart
import logging
import logging_json
formatter = logging_json.JSONFormatter(fields={
"level_name": "levelname",
"thread_name": "threadName"
})
handler = logging.StreamHandler()
handler.setFormatter(formatter)
logger = logging.getLogger()
logger.addHandler(handler)
logger.info({"key": "value"})
Requires Python 3.9 or later.
Verify before relying
- Whether the package is actively maintained or if dormant status signals end-of-life intent.
- Performance characteristics when formatting high-volume logging streams.
- Compatibility with async logging frameworks or concurrent logging scenarios.
Package facts
| License | MIT License Copyright (c) 2025 Colin Bounouar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 556 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 271,433/month — #8,222 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: logging_json-0.6.0-py3-none-any.whl
Keywords: logging, json
Tags
More Build Tools packages
Provides reusable utilities for Python…
permissive · top 100 on PyPI
tqdmWraps any iterable to display a real-time…
copyleft · top 100 on PyPI
pippip is the standard installer for Python…
permissive · top 100 on PyPI
hatchlingHatchling is a standards-compliant Python build…
permissive · top 100 on PyPI
grpcio-toolsGenerates Python gRPC service stubs and message…
permissive · top 1,000 on PyPI
pre-commitpre-commit is a framework for installing and…
permissive · top 1,000 on PyPI
jsonformatterFormats Python logging output as JSON, enabling…
permissive · top 15,000 on PyPI
logfmterFormats Python stdlib logging output as logfmt…
permissive · top 15,000 on PyPI
logstash_formatterFormats Python logging output as JSON objects…
permissive · top 15,000 on PyPI
JSON-log-formatterFormats Python logging records as JSON,…
permissive · top 5,000 on PyPI
logzerologzero provides pre-configured Python logging…
permissive · top 5,000 on PyPI
python-json-loggerFormats Python logging output as JSON, making…
permissive · top 1,000 on PyPI
daiquiriDaiquiri simplifies Python logging…
permissive · top 15,000 on PyPI
splunk-handlerA Python logging handler that sends log events…
permissive · top 5,000 on PyPI
mo-logsProvides structured JSON logging with…
copyleft · top 15,000 on PyPI
jsonobjectjsonobject provides a Python library for…
permissive · top 15,000 on PyPI