Log message formatting options
See original GitHub issueThe raven client had a defined log handler which let you use python’s built in logging configuration mechanisms to control how log messages looked when they were passed to sentry, however the new python-sdk does not appear to have any equivalent option. I have a number of apps where I have log messages managed by structlog
, where structlog
hooks into python’s logging and formatts everything nicely with pretty readable colours, nicely formatted timestamps, before it gets sent to stdout, however the combination of how python-sdk
hooks into logging, and the formatting of these messages means that the new sentry-sdk logging integration/handling makes an absolute mess of things producing unhelpful results in sentry.io like dozens of variations of [2m2019-01-03T07:16:00.573607Z[0m [[31m[1merror [0m] [1mcan_send_message is Fals...
each with one recorded error event, instead of a single can_send_message is False
with the correct count of error events.
What is the mechanism for the sentry-sdk to work with python’s logging formatters and libraries such as structlog?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:12
- Comments:26 (10 by maintainers)
Top GitHub Comments
@untitaker Thank you!
I actually got it sort of working now. Before I was using the
structlog
format… Which basically has aevent
key which contains the message. Now I changed it so[json-python-logger](https://github.com/madzak/python-json-logger)
takes care of outputting the json - which has the message in amessage
key. This now displays correctly in Sentry BUT doesn’t display the exception stack trace. For example:The sentry python lib will not look at
exception
key in this case and format it correctly in SentryHave same issue