Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

ExceptionlessLoggerProvider(Action<ExceptionlessConfiguration>) configures and disposes the shared ExceptionlessClient.Default

Đang mở
#389 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp
Lĩnh vực
backend, devtools

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ả

bug

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

What happens

  • When the provider is disposed, ExceptionlessClient.Default is disposed: its settings-update timer is stopped, its configuration and queue event handlers are detached, and its dependency resolver is disposed. Default is a Lazy singleton, 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 a LoggerFactory with factory.AddProvider(...) and the factory is disposed, or when the caller disposes the provider. (Through ILoggingBuilder.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 Default rather than a separate client. AddExceptionless(apiKey) also calls UseInMemoryStorage() and SetDefaultMinLogLevel(Trace) on Default, 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

Mở trong Codespaces

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.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của exceptionless/Exceptionless.Net

Tất cả issue của exceptionless/Exceptionless.Net

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.