ExceptionlessLoggerProvider(Action<ExceptionlessConfiguration>) configures and disposes the shared ExceptionlessClient.Default
Maintainer thường phản hồi trong vòng 6 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Read src/Platforms/Exceptionless.Extensions.Logging/ExceptionlessLoggerProvider.cs, especially the Action<ExceptionlessConfiguration> constructor and Dispose method, then check the overloads in ExceptionlessLoggerExtensions.cs. Confirm how the constructor creates and owns its client, and run the logging provider tests if available. Done means these overloads use an independent client and disposing the provider leaves ExceptionlessClient.Default usable; the issue notes draft PR #368 already proposes this change.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
In Exceptionless.Extensions.Logging 6.2.0, AddExceptionless(apiKey) and AddExceptionless(Action<ExceptionlessConfiguration>) are documented as using "a new client", but the ExceptionlessLoggerProvider(Action<ExceptionlessConfiguration>) constructor they call uses the process-wide ExceptionlessClient.Default and marks it as owned (_shouldDispose = true). Disposing the provider disposes Default, which the rest of the app is still using.
Where
- https://github.com/exceptionless/Exceptionless.Net/blob/5792f00d175f94a35fe0559c8e9999234a8163be/src/Platforms/Exceptionless.Extensions.Logging/ExceptionlessLoggerProvider.cs#L23-L31 (uses
ExceptionlessClient.Defaultand sets_shouldDispose = true) - https://github.com/exceptionless/Exceptionless.Net/blob/5792f00d175f94a35fe0559c8e9999234a8163be/src/Platforms/Exceptionless.Extensions.Logging/ExceptionlessLoggerProvider.cs#L43-L47 (disposes the client)
- https://github.com/exceptionless/Exceptionless.Net/blob/5792f00d175f94a35fe0559c8e9999234a8163be/src/Platforms/Exceptionless.Extensions.Logging/ExceptionlessLoggerExtensions.cs#L52-L84 (the overloads that call this constructor, documented as "using a new client")
What happens
- When the provider is disposed,
ExceptionlessClient.Defaultis disposed: its settings-update timer is stopped, its configuration and queue event handlers are detached, and its dependency resolver is disposed.Defaultis aLazysingleton, so it is never recreated, and everything else that uses it (ExceptionlessClient.Default.Submit*,services.AddExceptionless(),app.UseExceptionless(), the NLog and log4net integrations) keeps using the disposed instance. This happens when the provider is added to aLoggerFactorywithfactory.AddProvider(...)and the factory is disposed, or when the caller disposes the provider. (ThroughILoggingBuilder.AddExceptionless(...)the provider is registered as a pre-built instance, so the container does not dispose it.) - In every path, the configuration passed to these overloads is applied to
Defaultrather than a separate client.AddExceptionless(apiKey)also callsUseInMemoryStorage()andSetDefaultMinLogLevel(Trace)onDefault, which changes the behavior of every other integration that uses it.
Expected
The provider creates and owns its own ExceptionlessClient, as the XML docs say, and only disposes a client it created.
Steps to reproduce
using (var factory = new LoggerFactory())
factory.AddProvider(new ExceptionlessLoggerProvider(c => c.ApiKey = "API_KEY"));
// ExceptionlessClient.Default has now been disposed by the logger provider;
// for example, its internal settings timer is disposed.
ExceptionlessClient.Default.SubmitLog("after logger factory disposed");
Verified against the 6.2.0 NuGet packages: after the using block, ExceptionlessClient.Default is in its disposed state.
Suggested fix
Create a new client in the Action<ExceptionlessConfiguration> constructor (_client = new ExceptionlessClient();). The open draft PR #368 includes this change.
- Ngôn ngữ chính
- C#
- Star
- 573
- Fork
- 143
- Merge trung bình
- 5 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của exceptionless/Exceptionless.Net
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
exceptionless/Exceptionless.Net#391 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
exceptionless/Exceptionless.Net#390 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
bug
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
exceptionless/Exceptionless.Net#387 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
AWS Lambda detection never matches because the environment variable name has a trailing spaceĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
exceptionless/Exceptionless.Net#386 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
exceptionless/Exceptionless.Net#388 ·
Maintainer thường phản hồi trong vòng 6 ngày
Tất cả issue của exceptionless/Exceptionless.Net
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] Dashboard renders attachment links that resolve to 404 when the FILES binding is absentĐang mởbug 優先: 低
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
-
.NET area: storage bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Larson-Logan/medal-sync#61 ·
Maintainer thường phản hồi trong vòng 1 ngày