serilog-sinks-elasticsearch icon indicating copy to clipboard operation
serilog-sinks-elasticsearch copied to clipboard

Graceful failure if unable to connect to ES

Open gkruszewski opened this issue 3 years ago • 0 comments
trafficstars

Does this issue relate to a new feature or an existing bug?

  • [ ] Bug
  • [x] New Feature

What version of Serilog.Sinks.Elasticsearch is affected? Please list the related NuGet package. 8.4.1

What is the target framework and operating system? See target frameworks & net standard matrix.

  • [ ] netCore 2.0
  • [ ] netCore 1.0
  • [x] 4.8
  • [ ] 4.7
  • [ ] 4.6.x
  • [ ] 4.5.x

Please describe the current behavior? Exception is thrown if ES connection fails.

Please describe the expected behavior? Handle connection failures gracefully when calling new LoggerConfiguration().ReadFrom.Configuration. If the application is unable to connect the sink should fail gracefully using the existing fallback logic and allow the host to continue operation. Currently, if the ES connection fails the sink throws an exception. This only seems to be applicable when instantiating a LoggerConfiguration directly, the UseSerilog delegate seems to handle the exception appropriately. Unfortunately, I don't have an IWebHost to work with and need to construct the LoggerConfiguraiton directly instead of using the extension method.

If the current behavior is a bug, please provide the steps to reproduce the issue and if possible a minimal demo of the problem

image

gkruszewski avatar May 11 '22 18:05 gkruszewski