Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta
#389 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 6 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
35/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
csharp
Domínio
backend, devtools

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
C#
Estrelas
573
Forks
143
Merge médio
5d 9h
PRs com merge (30d)
1

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de exceptionless/Exceptionless.Net

Todas as issues de exceptionless/Exceptionless.Net

Issues semelhantes

Mais issues de C#

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.