You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2026. It is now read-only.
The StructuredLogHandler appends a Traceback after the json structured log message.
This causes a second unstructured log entry with just the traceback when the handler is used in a Google Cloud Function.
{"message": "Failed\nTraceback (most recent call last):\n File \"main.py\", line 10, in <module>\n raise Exception(\"Test\")\nException: Test", "severity": "ERROR", "logging.googleapis.com/labels": {}, "logging.googleapis.com/trace": "", "logging.googleapis.com/spanId": "", "logging.googleapis.com/sourceLocation": {"line": 12, "file": "main.py", "function": "<module>"}, "httpRequest": {} }
Traceback (most recent call last):
File "main.py", line 10, in <module>
raise Exception("Test")
Exception: Test
The traceback appears twice. Once inside the structured log message and again after it. This happens because a logging.Formatter is used which always appends the traceback if exc_info or exc_text is present.
The StructuredLogHandler appends a Traceback after the json structured log message.
This causes a second unstructured log entry with just the traceback when the handler is used in a Google Cloud Function.
Code example
Output
The traceback appears twice. Once inside the structured log message and again after it. This happens because a logging.Formatter is used which always appends the traceback if exc_info or exc_text is present.