From bb228f35237879b0cae93e3b5efab468b94a1e5b Mon Sep 17 00:00:00 2001 From: Nick Barrett Date: Fri, 8 Oct 2021 12:08:25 +0100 Subject: Include exception in json logging (#11028) --- synapse/logging/_terse_json.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'synapse/logging/_terse_json.py') diff --git a/synapse/logging/_terse_json.py b/synapse/logging/_terse_json.py index 6e82f7c7f1..b78d6e17c9 100644 --- a/synapse/logging/_terse_json.py +++ b/synapse/logging/_terse_json.py @@ -65,6 +65,12 @@ class JsonFormatter(logging.Formatter): if key not in _IGNORED_LOG_RECORD_ATTRIBUTES: event[key] = value + if record.exc_info: + exc_type, exc_value, _ = record.exc_info + if exc_type: + event["exc_type"] = f"{exc_type.__name__}" + event["exc_value"] = f"{exc_value}" + return _encoder.encode(event) -- cgit 1.4.1