pygelf provides logging handlers for the GELF (Graylog Extended Log Format) specification, allowing Python applications to send logs to Graylog servers or other GELF-compatible log management systems. It supports UDP, TCP, and HTTP transport protocols, including features like compression and chunking for large messages. The current version is 0.4.3, and it receives active maintenance with a moderate release cadence.
pip install pygelfVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to configure a Python logger with `GELFUDPHandler` to send log messages to a Graylog instance. It shows basic info, warning, and exception logging, including how to pass extra fields to GELF. Remember to replace placeholder host/port or set them via environment variables to match your Graylog setup.
Verify your Graylog input type and its listening address/port. For UDP, the default port is 12201; for TCP, it's 12202; for HTTP, it's typically 12201 (HTTP GELF input) on a dedicated Graylog HTTP input.
Set `compress=True` (defaults to `zlib`) on your handler. pygelf handles chunking automatically for UDP, but compression helps reduce the number of chunks and total payload size, improving reliability for large messages.
Add `include_extra_fields=True` to your GELF handler initialization, e.g., `GELFUDPHandler(host=..., include_extra_fields=True)` to ensure these fields are sent.
No dependency data recorded yet.