skillfed

pygelf

Logging handlers with GELF support

pygelf v0.4.3 388.3K downloads/30d#7,036 on PyPI85
Permissive license MIT AGING released

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 pygelf

uv

uv add pygelf

poetry

poetry add pygelf

Installing 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

Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries :: Python ModulesTopic :: System :: Logging

Tags

graylog logging handlergelf protocol pythonsend logs to graylogpython gelf clientgraylog extended log formatcentralized logging graylogtcp udp logging handler
graylog-integrationstructured-logging

More Python Modules packages