I’m trying to switch from raven to the Sentry python_sdk. Sending errors is working as expected, but it is not sending events for logs of the INFO
level. I already changed the event_level of the LoggingIntegration
to logging.INFO
:
import logging
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.logging import LoggingIntegration
def before_send(event, hint):
if "exc_info" in hint:
exc_type, exc_value, tb = hint["exc_info"]
if isinstance(exc_value, KeyboardInterrupt):
return None
return event
sentry_sdk.init(
dsn="...",
integrations=[
DjangoIntegration(), LoggingIntegration(level=logging.INFO, event_level=logging.INFO)
],
before_send=before_send,
)
I also attached the sentry
handler which I can also retrieve from the logger. The Level is INFO
as well. The logger of concern is called MyLogger
as stated with the variable LOGGER_NAME
.
LOGGER_NAME = "MyLogger"
LOGGING = {
"version": 1,
"disable_existing_loggers": True,
"formatters": {"verbose": {"format": "%(levelname)s %(asctime)s %(module)s " "%(process)d %(thread)d %(message)s"}},
"handlers": {
"sentry": {
"level": "INFO",
"class": "sentry_sdk.integrations.logging.EventHandler",
},
"console": {"level": "DEBUG", "class": "logging.StreamHandler", "formatter": "verbose"},
},
"loggers": {
"django": {"propagate": False, "handlers": ["sentry", "console"]},
"django.request": {"level": "ERROR", "propagate": False, "handlers": ["sentry", "console"]},
"django.db.backends": {"level": "ERROR", "propagate": False, "handlers": ["sentry", "console"]},
"raven": {"level": "WARNING", "propagate": False, "handlers": ["sentry", "console"]},
"sentry.errors": {"level": "WARNING", "propagate": False, "handlers": ["sentry", "console"]},
LOGGER_NAME: {"level": "INFO", "propagate": False, "handlers": ["sentry"]},
"{}.test".format(LOGGER_NAME): {"level": "INFO", "propagate": False, "handlers": ["console"]},
},
}
Does anyone have an idea how I can make this work?