The logs are always being written to both Elastic Search and Local Log Files (when used as a Failure Sink) . This should not be the case. Local Log Files should be created only when the application fails to write logs to Elasticsearch
Serilog.Debugging.SelfLog.Enable(TextWriter.Synchronized(file));
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.WriteTo.Elasticsearch(new ElasticsearchSinkOptions
{
EmitEventFailure = EmitEventFailureHandling.WriteToSelfLog |
EmitEventFailureHandling.WriteToFailureSink |
EmitEventFailureHandling.RaiseCallback,
FailureSink = new RollingFileSink("./failures.txt", new JsonFormatter(),null,30)
})
.CreateLogger();
Error on SelfLog: Caught exception while preforming bulk operation to Elasticsearch: Elasticsearch.Net.ElasticsearchClientException: No connection could be made because the target machine actively refused it. Call: Status code unknown from: POST /_bulk ---> System.Net.Http.HttpRequestException: No connection could be made because the target machine actively refused it ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it