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
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 1/5 1-3 小时 新手友好度 89/100
getsentry/sentry-dotnet#5833 · 1 条评论 ·
维护者通常 1 天内回复
-
area: core priority: low type: bug
难度 2/5 1-3 小时 新手友好度 74/100
RicoSuter/Namotion.Interceptor#863 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
bitfoundation/bitplatform#14428 · 1 条评论 ·
维护者通常 1 天内回复
-
area-cli
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复