pygelf
Logging handlers with GELF support
What it is and what it does
pygelf is a Python logging library that bridges the standard logging module to Graylog servers by providing handlers that format and transmit logs in GELF format. It supports five transport protocols—TCP, UDP, TLS (encrypted TCP), HTTP, and HTTPS—allowing you to choose based on your network and security requirements. The library handles the GELF message structure automatically, including mandatory fields like version, timestamp, syslog-compliant log level, hostname, and optional stack traces for exceptions.
You integrate it by adding one or more handlers to your logger, specifying the target server's host and port. The package supports optional features like debug mode (which adds file, line, module, and function metadata), static and dynamic custom fields, environment variable injection, message compression, and TLS certificate validation. It has no external runtime dependencies, making it lightweight to add to existing Python projects.
Use it for:
- Centralize logs from a Python application to a Graylog instance for aggregated monitoring and analysis.
- Send application logs over encrypted TLS to a remote Graylog server in a secure network environment.
- Add structured metadata (app name, request ID, user context) to each log entry for better searchability in Graylog.
- Route exception stack traces and debug information to Graylog for post-mortem analysis.
- Integrate logging into a Flask or Django application configuration file to send logs via HTTP to Graylog.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides Python logging handlers that send log messages to Graylog servers using the GELF (Graylog Extended Log Format) protocol over TCP, UDP, TLS, HTTP, or HTTPS.
Yes, if you are already using Graylog and need Python logging integration. The package is stable, has no dependencies, and supports modern Python versions. However, maintenance is aging (last release 426 days ago), so verify that it works with your specific Graylog version and Python release before committing to production. No known security vulnerabilities.
Install
pygelf on PyPI
pip
pip install pygelfuv
uv add pygelfpoetry
poetry add pygelfInstalling pygelf
Before you install
Low friction to install; no runtime dependencies. Maintenance is aging—last release was 426 days ago, though the repository remains active with a recent commit on 2025-06-25 and modest community engagement (85 stars).
License in practice
MIT license is permissive, allowing use in commercial and proprietary projects with minimal restrictions beyond attribution.
Quickstart
pip install pygelf
from pygelf import GelfTcpHandler
import logging
logger = logging.getLogger()
logger.addHandler(GelfTcpHandler(host='127.0.0.1', port=9401))
logger.info('hello gelf')
Requires a running GELF-compatible server (e.g., Graylog) listening on the specified host and port.
Verify before relying
- Whether the package works reliably with Python 3.13 or if 3.13 support is merely declared but untested.
- Current state of PyPy compatibility given the aging maintenance status.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 426 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 388,303/month — #7,036 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pygelf-0.4.3-py3-none-any.whl
Keywords: logging, udp, tcp, ssl, tls, graylog2, graylog, gelf
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
graypyProvides Python logging handlers that format…
permissive · top 15,000 on PyPI
python3-logstashA Python logging handler that forwards log…
permissive · top 15,000 on PyPI
python-logstashSends Python log records to Logstash over UDP…
permissive · top 15,000 on PyPI
python-logging-lokiA Python logging handler that sends log records…
permissive · top 5,000 on PyPI
logzio-python-handlerA Python logging handler that sends logs in…
permissive · top 5,000 on PyPI
loki-logger-handlerA logging handler that sends Python log…
permissive · top 15,000 on PyPI
PyCampbellCR1000Communicates with Campbell CR1000-type…
copyleft · top 15,000 on PyPI
aws-logging-handlersRoutes Python logging records to AWS S3 and…
permissive · top 15,000 on PyPI
splunk-handlerA Python logging handler that sends log events…
permissive · top 5,000 on PyPI
questdbA Python client library for QuestDB that sends…
permissive · top 15,000 on PyPI