Include exception in json logging (#11028)

This commit is contained in:
Nick Barrett 2021-10-08 12:08:25 +01:00 committed by GitHub
parent 0b4d5ce5e3
commit bb228f3523
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 0 deletions

View file

@ -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)