ExceptionlessLoggerProvider(Action<ExceptionlessConfiguration>) configures and disposes the shared ExceptionlessClient.Default
維護者通常 6 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- C#
- 星號
- 573
- 分支
- 143
- 平均合併
- 5 天 9 小時
- 30 天內合併 PR
- 1
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
exceptionless/Exceptionless.Net 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 86/100
exceptionless/Exceptionless.Net#391 ·
維護者通常 6 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
exceptionless/Exceptionless.Net#390 ·
維護者通常 6 天內回覆
-
bug
難度 1/5 1-3 小時 新手友好度 88/100
exceptionless/Exceptionless.Net#387 ·
維護者通常 6 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 76/100
exceptionless/Exceptionless.Net#386 ·
維護者通常 6 天內回覆
-
bug
難度 3/5 1-2 天 新手友好度 72/100
exceptionless/Exceptionless.Net#388 ·
維護者通常 6 天內回覆
查看 exceptionless/Exceptionless.Net 的全部 Issue
相似的 Issue
-
bug effort:S P3
難度 2/5 1-3 小時 新手友好度 85/100
nightscout/nocturne#3093 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 67/100
維護者通常 3 天內回覆
-
難度 1/5 1 小時以內 新手友好度 85/100
-
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100