JSON log formatter for Graylog
Project description
graylog-json-formatter
JSON log formatter for Graylog — a logging.Formatter that emits structured JSON,
passing record extra fields through and mapping Python log levels to Graylog severities.
Installation
pip install entirius-py-graylog-json-formatter
Usage
import logging
import graylog_json_formatter
json_handler = logging.FileHandler(filename="app.json.log")
json_handler.setFormatter(graylog_json_formatter.GraylogJSONFormatter())
logger = logging.getLogger("my_json")
logger.addHandler(json_handler)
logger.info("Order created", extra={"order_id": "18"})
In Django settings.py:
from graylog_json_formatter import GraylogJSONFormatter
LOGGING["formatters"]["graylog_json"] = {"()": GraylogJSONFormatter}
LOGGING["handlers"]["handler_name"] = {
"level": "DEBUG",
"class": "logging.FileHandler",
"filename": os.path.join(LOG_DIR, "app.json.log"),
"encoding": "utf8",
"formatter": "graylog_json",
}
Development
make install # sync dependencies (uv)
make check # lint + format check (ruff)
make test # test suite (pytest)
Development and agent instructions: AGENTS.md.
License
Mozilla Public License 2.0 — see LICENSE.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file entirius_py_graylog_json_formatter-2.0.0.tar.gz.
File metadata
- Download URL: entirius_py_graylog_json_formatter-2.0.0.tar.gz
- Upload date:
- Size: 23.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1d6ddef6a5774a43d36bcfa925abf459debd1edb1dc5f4c5c9b60400c275d0e
|
|
| MD5 |
dff809eeaed1c17afadc423b3f426651
|
|
| BLAKE2b-256 |
2ec562d89e0da15f44a944e06dfdc520821ebf143f44d949feb234824266cff6
|
File details
Details for the file entirius_py_graylog_json_formatter-2.0.0-py3-none-any.whl.
File metadata
- Download URL: entirius_py_graylog_json_formatter-2.0.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9559af5aad3cd6ada8a8f63205f1a8a20bff51b6534b51530d9d6df3890edbe
|
|
| MD5 |
214b321d0894a53f4182cf6df8f71f7a
|
|
| BLAKE2b-256 |
9515811f49a77af6d89b4d04b0f44c98bff78fd9483946c52456776fa77e15f4
|