diff --git a/sentry_sdk/integrations/logging.py b/sentry_sdk/integrations/logging.py index 895f09f780..ee6bb8e1d1 100644 --- a/sentry_sdk/integrations/logging.py +++ b/sentry_sdk/integrations/logging.py @@ -91,6 +91,10 @@ def setup_once(): def sentry_patched_callhandlers(self, record): # type: (Any, LogRecord) -> Any + # keeping a local reference because the + # global might be discarded on shutdown + ignored_loggers = _IGNORED_LOGGERS + try: return old_callhandlers(self, record) finally: @@ -98,7 +102,7 @@ def sentry_patched_callhandlers(self, record): # the integration. Otherwise we have a high chance of getting # into a recursion error when the integration is resolved # (this also is slower). - if record.name not in _IGNORED_LOGGERS: + if ignored_loggers is not None and record.name not in ignored_loggers: integration = Hub.current.get_integration(LoggingIntegration) if integration is not None: integration._handle_record(record)