Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (
Help us improve Python packaging - Donate today!

Python logging implementation of GELF (graylog extended log format)

Project Description


from pygelf import GelfTcpHandler, GelfUdpHandler
import logging

logger = logging.getLogger()
logger.addHandler(GelfTcpHandler('', 9401))
logger.addHandler(GelfUdpHandler('', 9402))'hello gelf')


Each handler has the following parameters:

  • host: ip address of the GELF input
  • port: port of the GELF input
  • debug (false by default): if true, each log message will include debugging info: module name, file name, line number, method name
  • compress (true by default): if true, compress log messages before send them to the server

In addition, UDP handler has one extra field:

  • chunk_size (1300 by default) - maximum length of the message. If log length exceeds this value, it splits into multiple chunks (see section “chunked GELF”) with the length equals to this value. This parameter must be less than the MTU. If the logs don’t seem to be delivered, try to reduce this value.

Additional fields

If you need to include some static fields into your logs, simply pass them to the constructor of the handler. Each additional field shoud start with underscore. You can’t add field ‘_id’ as well.


handler = GelfUdpHandler('', 9402, _app_name='pygelf', _something=11)

Or using kwargs:

fields = {
    '_app_name': 'gelf_test',
    '_app_version': '1.5',
    '_something': 11

handler = GelfUdpHandler('', 9402, **fields)
Release History

Release History

This version
History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
gelf-0.1.tar.gz (3.1 kB) Copy SHA256 Checksum SHA256 Source Aug 16, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting