Registry / observability / logstash-formatter

logstash-formatter

JSON →
library0.5.17pypypi✓ verified 85d ago

A JSON log formatter for logstash, typically used with Python's logging module. Current version 0.5.17. Infrequently updated; last release in 2019.

pip install logstash-formatter
INSTALL
IMPORT
SIG · LOGSTASH-FORMATTER
L
logstash-formatter
observabilitypythonv0.5.17
Install
2.4s avg
Import
34ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.5.17 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.036s · 19.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.4s · import 0.032s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

LogstashFormatter
from logstash_formatter import LogstashFormatter
from logstash_formatter.formatter import LogstashFormatter
Old import path from earlier versions; now use top-level module.

Basic setup with a stream handler. The extra dict becomes JSON fields.

import logging from logstash_formatter import LogstashFormatter handler = logging.StreamHandler() formatter = LogstashFormatter() handler.setFormatter(formatter) logger = logging.getLogger('my_logger') logger.addHandler(handler) logger.setLevel(logging.INFO) logger.info('Hello, logstash!', extra={'custom_field': 'value'})
Debug
Known issues
gotchaMessage string is automatically included; do not embed JSON in the message itself as it may interfere with parsing.
fix
Use the extra parameter to add structured data instead of formatting it into the message string.
affects: all
gotchaTimestamp defaults to the current time in UTC in ISO8601 format; timezone awareness may cause issues if your logs are not in UTC.
fix
Set the 'format' parameter to 'UNIX' or custom format, or ensure your logger's timezone is consistent.
affects: all
deprecatedPython 2 support is effectively abandoned; the library may not install or function correctly on Python 2.
fix
Upgrade to Python 3. Use version 0.5.17 on Python 3.6+.
affects: 0.5.x
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'logstash_formatter'
Package not installed or import path incorrect.
fix
Run 'pip install logstash-formatter' and use 'from logstash_formatter import LogstashFormatter'.
TypeError: __init__() got an unexpected keyword argument 'version'
Passing parameters that don't match the constructor signature (e.g., 'version' instead of 'fmt' or 'datefmt').
fix
Check the constructor: LogstashFormatter(fmt=None, datefmt=None, extra=None). Remove unsupported arguments.
AttributeError: 'LogstashFormatter' object has no attribute '_style'
Incompatibility with Python logging internals in newer Python versions (3.8+).
fix
Pin to logstash-formatter==0.5.17 and ensure Python >=3.6. If issues persist, consider switching to python-json-logger.
Upgrade
Version history
0.5.17latest on PyPI · released Feb 13, 2018
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
2
Resources
logstash-formatter — pip install logstash-formatter · libregistry