Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

A logging formatter that appends extra data as JSON, e.g. for loggly

License

Notifications You must be signed in to change notification settings

opbeat/python-logging-json-formatter

Repository files navigation

python-logging-json-formatter

A logging Formatter that appends extra data as JSON, e.g. for loggly

USAGE

Using dictConfig

import logging.config

logging.config.dictConfig({
    'version': 1,
    'formatters': {
        'append_json': {
            '()': 'logging_json_formatter.AppendJSONFormatter',
            'format': '%(asctime)s %(name)s %(levelname)s %(funcName)s  %(filename)s:%(lineno)s %(message)s',

            # only use a specific set of keys
            'limit_keys_to': ['org_uuid', 'app_uuid'],

            # force keys that are ignored by default
            'force_keys': ('levelname', 'lineno'),
        }
    },
    'handlers': {
        'syslog': {
            'level': 'ERROR',
            'class': 'logging.handlers.SysLogHandler'
            'address': '/dev/log',
            'formatter': 'append_json'
        },
    },
}

About

A logging formatter that appends extra data as JSON, e.g. for loggly

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published