elastic / ecs-dotnet

https://www.elastic.co/guide/en/ecs-logging/dotnet/current/setup.html
Apache License 2.0
108 stars 54 forks source link

[BUG] Elastic.Extensions.Logging stops logging after configuration refresh events #395

Closed moikmellah closed 1 month ago

moikmellah commented 1 month ago

ECS integration/library project(s) (e.g. Elastic.CommonSchema.Serilog): Elastic.Extensions.Logging v8.11.0

ECS schema version (e.g. 1.4.0): latest

ECS .NET assembly version (e.g. 1.4.2): latest

.NET framework / OS: .NET 8.0, .NET Framework 4.7.2

Description of the problem, including expected versus actual behavior: On configuration refresh events, Elastic logging halts entirely while other sinks continue logging correctly. Expected: Logging should continue after configuration refresh events.

Steps to reproduce:

  1. Configure any .NET application with Elastic.Extensions.Logging as a provider
  2. Add a JSON file to configuration with file watching enabled
  3. Update the JSON file while the app is running to trigger an OptionsMonitor.OnReload event
  4. Log events are no longer sent from the Elastic provider (other providers still work, though)
moikmellah commented 1 month ago

Pretty sure it's because _channel is being disposed of when configs are refreshed, but nothing is propagating the new _channel to any loggers which have already been created. PR #396 submitted for a possible fix.

**Edit: Sorry, had to redo the PR to comply with the CLA.