ExceptionlessLoggerProvider(Action<ExceptionlessConfiguration>) configures and disposes the shared ExceptionlessClient.Default
Los mantenedores suelen responder en 6 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 35/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C#
- Estrellas
- 573
- Forks
- 143
- Merge medio
- 5 d 9 h
- PR fusionados (30 d)
- 1
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de exceptionless/Exceptionless.Net
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
exceptionless/Exceptionless.Net#391 ·
Los mantenedores suelen responder en 6 días
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
exceptionless/Exceptionless.Net#390 ·
Los mantenedores suelen responder en 6 días
-
bug
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
exceptionless/Exceptionless.Net#387 ·
Los mantenedores suelen responder en 6 días
-
AWS Lambda detection never matches because the environment variable name has a trailing spaceAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
exceptionless/Exceptionless.Net#386 ·
Los mantenedores suelen responder en 6 días
-
bug
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
exceptionless/Exceptionless.Net#388 ·
Los mantenedores suelen responder en 6 días
Todos los issues de exceptionless/Exceptionless.Net
Issues similares
-
bug effort:S P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
nightscout/nocturne#3093 ·
Los mantenedores suelen responder en 1 día
-
Add dependency list in documentsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
Los mantenedores suelen responder en 3 días
-
Add 'upm' tag on githubAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100