Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A structured logger for Fluentd (Python)
branch: master

Merge pull request #32 from yyuu/fluent-travis-coverall

fluent/fluent-logger-python should use its own account for and
latest commit 5b346cfeaf
@kzk kzk authored

A Python structured logger for Fluentd

Build Status Coverage Status

Many web/mobile applications generate huge amount of event logs (c,f. login, logout, purchase, follow, etc). To analyze these event logs could be really valuable for improving the service. However, the challenge is collecting these logs easily and reliably.

Fluentd solves that problem by having: easy installation, small footprint, plugins, reliable buffering, log forwarding, etc.

fluent-logger-python is a Python library, to record the events from Python application.


  • Python 2.6 or greater including 3.x


This library is distributed as 'fluent-logger' python package. Please execute the following command to install it.

$ pip install fluent-logger


Fluentd daemon must be launched with a tcp source configuration:

  type forward
  port 24224

To quickly test your setup, add a matcher that logs to the stdout:

<match app.**>
  type stdout


Event-Based Interface

First, you need to call logger.setup() to create global logger instance. This call needs to be called only once, at the beggining of the application for example.

By default, the logger assumes fluentd daemon is launched locally. You can also specify remote logger by passing the options.

from fluent import sender

# for local fluent

# for remote fluent
sender.setup('app', host='host', port=24224)

Then, please create the events like this. This will send the event to fluent, with tag 'app.follow' and the attributes 'from' and 'to'.

from fluent import event

# send event to fluentd, with 'app.follow' tag
event.Event('follow', {
  'from': 'userA',
  'to':   'userB'

Python logging.Handler interface

This client-library also has FluentHandler class for Python logging module.

import logging
from fluent import handler

l = logging.getLogger('fluent.test')
l.addHandler(handler.FluentHandler('app.follow', host='host', port=24224)){
  'from': 'userA',
  'to': 'userB'


Testing can be done using nose.


Patches contributed by those people.


Apache License, Version 2.0

Something went wrong with that request. Please try again.