Skip to main content

JSON formatter for graylog JSON extractor.

Project description

GrayLogJSONFormatter formatted LogRecord as JSON object for graylog JSON extractor. JSON object include LogRecord attributes as default_keys and include extra attributes: source, message, asctime and data.



from logging import config

        'version': 1,
        'disable_existing_loggers': True,
        'formatters': {
            'graylog': {
                '()': 'graylog_json_formatter.GrayLogJSONFormatter',
                'format': '({levelname}) | {name} | [{asctime}]: '
                          'File {pathname}:{lineno}" - {funcName}() | {message}',
                'style': '{',
                'source': 'test',
        'handlers': {
            'console': {
                'level': 'DEBUG',
                'class': 'logging.StreamHandler',
                'formatter': 'graylog',
            'graylog': {
                'level': 'DEBUG',
                'class': 'logging.handlers.SysLogHandler',
                'formatter': 'graylog',
                'address': ('localhost', 10000),
        'loggers': {
            'test': {
                'level': 'DEBUG',
                'handlers': ['console', 'graylog'],
                'propagate': False,

    logger = logging.getLogger('test')


# extra usage
logger.debug('test message: % | %s', 1, 2, extra={'data': {'key': 'value', 'int_key': 12})

Graylog extract extra as data-key and data-int_key fields.

Project details

Download files

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

Files for graylog-json-formatter, version 0.0.2
Filename, size & hash File type Python version Upload date
graylog_json_formatter-0.0.2-py2.py3-none-any.whl (15.9 kB) View hashes Wheel py2.py3
graylog-json-formatter-0.0.2.tar.gz (3.5 kB) View hashes Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page