-
Notifications
You must be signed in to change notification settings - Fork 537
Debug logs duplication due to incorrect configuration #3944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Good idea @nkhitrov |
Thanks @nkhitrov for the proposed solution, too -- added it. The fix will be out with the next SDK release, probably next week. |
This reverts commit 3793084, which made the SDK consider parent loggers when determining if the Sentry SDK should log debug messages. However, we should not consider parent loggers, since we only want the SDK to log debug messages when configured to do so via `debug=True` (in `sentry_sdk.init`), the `SENTRY_DEBUG` environment variable, or via a specific logger configuration for `sentry_sdk.errors`. With 3793084, a custom root logger configuration would also cause SDK logs to be emitted. The issue 3793084 was meant to fix (#3944) appears to have been caused by user error, not a bug in the SDK. Fixes #4266
Hi @nkhitrov – just writing to let you know that we are going to revert your proposed fix (#4133) because it caused a bug (#4266) where folks with custom log configurations were unexpectedly getting a bunch of debug logs from the Sentry SDK. The change in behavior was due to #4133, and we realized at that point that we in fact did not want the SDK to consider parent loggers when setting up the SDK logger. We are going to need to come up with a more robust solution for your use case. I will reopen your issue. |
This reverts commit 3793084, which made the SDK consider parent loggers when determining if the Sentry SDK should log debug messages. However, we should not consider parent loggers, since we only want the SDK to log debug messages when configured to do so via `debug=True` (in `sentry_sdk.init`), the `SENTRY_DEBUG` environment variable, or via a specific logger configuration for `sentry_sdk.errors`. With 3793084, a custom root logger configuration would also cause SDK logs to be emitted. The issue 3793084 was meant to fix (#3944) appears to have been caused by user error, not a bug in the SDK. Fixes #4266
As a workaround after we revert our previous fix, you can either disable debug logs for the Sentry SDK, or if you need the debug logs, you can add these lines after the sentry_sdk_logger = logging.getLogger("sentry_sdk.errors")
sentry_sdk_logger.addHandler(handler)
sentry_sdk_logger.setLevel(LOG_LEVEL) In either case, you would not set |
This reverts commit 3793084, which made the SDK consider parent loggers when determining if the Sentry SDK should log debug messages. However, we should not consider parent loggers, since we only want the SDK to log debug messages when configured to do so via `debug=True` (in `sentry_sdk.init`), the `SENTRY_DEBUG` environment variable, or via a specific logger configuration for `sentry_sdk.errors`. With 3793084, a custom root logger configuration would also cause SDK logs to be emitted. The issue 3793084 was meant to fix (#3944) will require a different fix. Fixes #4266
How do you use Sentry?
Self-hosted/on-premise
Version
2.19.2
Steps to Reproduce
Sentry duplicates log records when you set debug mode via
sentry_sdk.init()
and configure handler in root logger only.In my project I use
structlog
so full code example with itExpected Result
Sentry does not write log records via own stream handler and use parent (root) logger configuration
Output:
Actual Result
Output:
Possible fix
In
debug.py
we should change configuration check and use special logger method to check parent handlers toofrom this
to this
The text was updated successfully, but these errors were encountered: