Skip to content

Instantly share code, notes, and snippets.

@ikeikeikeike
Created March 13, 2012 11:46
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ikeikeikeike/2028340 to your computer and use it in GitHub Desktop.
Save ikeikeikeike/2028340 to your computer and use it in GitHub Desktop.
django logging fluentd
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': "%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]"
},
},
'handlers': {
'fluentinfo':{
'level':'INFO',
'class':'fluent.handler.FluentHandler',
'formatter': 'verbose',
'tag':'app.info',
'host':'localhost',
'port':24224,
# 'timeout':3.0,
# 'verbose': False
},
'fluentdebug':{
'level':'DEBUG',
'class':'fluent.handler.FluentHandler',
'formatter': 'verbose',
'tag':'app.debug',
'host':'localhost',
'port':24224,
# 'timeout':3.0,
'verbose': True
},
},
'loggers': {
'app.debug': {
'handlers': ['fluentdebug'],
'level': 'DEBUG',
'propagate': True,
},
'app.info': {
'handlers': ['fluentinfo'],
'level': 'DEBUG',
'propagate': True,
},
}
}
@mordaha
Copy link

mordaha commented Jun 7, 2016

for future googlers :)

if you using fluentd to send log entries to elasticsearch (via fluent-plugin-elasticsearch), you must use fluent.handler.FluentRecordFormatter formatter. Coz fluent-plugin-elasticsearch wants pure json as log entry.

Something like this:

...
    'formatters': {
        'fluentd': {
            '()': 'fluent.handler.FluentRecordFormatter',
            'format': {
                'level': '%(levelname)s',
                'hostname': '%(hostname)s',
                'where': '%(module)s',
            }
        }
    },
...
    'handlers': {
       'fluentd':{
            'level': 'INFO',
            'class': 'fluent.handler.FluentHandler',
            'formatter': 'fluentd',
            'tag': 'django.log',
      }

@dennisbyrne
Copy link

Change DEBUG to INFO on line 39.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment