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.
Example
configure:
from logging import config config.dictConfig({ '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')
logging:
# 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.
Source Distribution
Built Distribution
Close
Hashes for graylog-json-formatter-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdeb997f915b635e22b384bc384844b8bf2d626a2280bfcd8451d7d035f87899 |
|
MD5 | 4df0344be4f4beebb4b971de78a77d3b |
|
BLAKE2b-256 | 00ea2f3652855aba0078c00d4a9d217275dc134ef816d68eb90306262f455a8d |
Close
Hashes for graylog_json_formatter-0.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 417b16f420e03bcf443847779dc0a144c120263fb1e5d2bad43dfe1036352c94 |
|
MD5 | 2713d946005c2d8cf201689cb57898f4 |
|
BLAKE2b-256 | 6eb72126c84b489b23e2a0126f82c6dd9497d9453b3370f583bec4f50f99996b |