Используй
.exception() вместо .error(), чтобы в лог вместе с исключением попадал tracebackПример:
import logging
LOGGER = logging.getLogger()
try:
{}["not_present"]
except Exception as exc:
LOGGER.error(exc) # только сообщение об ошибке
# -> 'not_present'
try:
{}["not_present"]
except Exception as exc:
LOGGER.exception(exc) # сообщение + traceback
# -> 'not_present'
# Traceback (most recent call last):
# File "my_module.py", line 12, in <module>
# KeyError: 'not_present'
👉 @PythonPortal