{"library":"logstash-python-formatter","title":"Logstash Python Formatter","description":"This library provides a Python logging formatter designed to output log data as JSON objects compatible with Logstash json filters. It enables standard Python logging to produce structured logs that can be easily ingested and parsed by Logstash. The current version is 0.1.2, released in 2018, indicating a low or inactive release cadence.","language":"python","status":"maintenance","last_verified":"Sun May 17","install":{"commands":["pip install logstash_formatter"],"cli":null},"imports":["from logstash_formatter import LogstashFormatterV1"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import logging\nfrom logstash_formatter import LogstashFormatterV1\nimport sys\n\n# Configure a logger\nlogger = logging.getLogger('my_app')\nlogger.setLevel(logging.INFO)\n\n# Create a StreamHandler to output logs to console\nhandler = logging.StreamHandler(sys.stdout)\n\n# Create an instance of LogstashFormatterV1\n# You can pass 'fmt' as a JSON string to add default extra fields or override source_host\n# For example: formatter = LogstashFormatterV1(fmt='{\"extra\": {\"service\": \"my-service\"}}')\nformatter = LogstashFormatterV1()\n\n# Set the formatter for the handler\nhandler.setFormatter(formatter)\n\n# Add the handler to the logger\nlogger.addHandler(handler)\n\n# Log messages\nlogger.info('This is a simple info message.')\nlogger.warning('This is a warning message with some context.', extra={'user_id': 123, 'transaction_id': 'abc-123'})\n\ntry:\n    1 / 0\nexcept ZeroDivisionError:\n    logger.error('An error occurred!', exc_info=True, extra={'error_code': 500})\n\n# Logging a dictionary directly as a message (fields are merged into the top level)\nlogger.info({'event': 'user_login', 'username': 'testuser'})","lang":"python","description":"This quickstart demonstrates how to configure the standard Python logging module to use `LogstashFormatterV1`. It sets up a basic logger with a stream handler, applies the formatter, and shows examples of logging simple messages, messages with extra fields, and exceptions, all formatted as JSON. The `LogstashFormatterV1` handles conversion of `msg` to `@message` and integrates `extra` dictionary fields.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":null,"pypi_latest":"0.1.2","is_stale":null,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":2.5,"avg_import_s":0.04,"wheel_type":"sdist"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"logstash_formatter","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.03,"mem_mb":1.4,"disk_size":"67.3M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"logstash_formatter","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":2,"import_time_s":0.02,"mem_mb":1.4,"disk_size":"139M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"logstash_formatter","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.05,"mem_mb":1.7,"disk_size":"74.2M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"logstash_formatter","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":2.1,"import_time_s":0.05,"mem_mb":1.7,"disk_size":"145M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"logstash_formatter","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.04,"mem_mb":1.3,"disk_size":"64.1M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"logstash_formatter","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":3.2,"import_time_s":0.04,"mem_mb":1.3,"disk_size":"135M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"logstash_formatter","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.04,"mem_mb":1.6,"disk_size":"60.7M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"logstash_formatter","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":2.8,"import_time_s":0.04,"mem_mb":1.4,"disk_size":"134M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"logstash_formatter","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.02,"mem_mb":1.4,"disk_size":"66.5M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"logstash_formatter","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"clean","install_time_s":2.4,"import_time_s":0.02,"mem_mb":1.4,"disk_size":"138M"}]}}