# ElasticSearch : Failure Sink always running

**URL:** <https://discuss.elastic.co/t/elasticsearch-failure-sink-always-running/299293>\
**Category:** Elasticsearch\
**Created:** [March 10, 2022, 5:25am UTC](https://discuss.elastic.co/t/elasticsearch-failure-sink-always-running/299293 "2022-03-10T05:25:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adesh\_Agarwal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adesh_agarwal/32/102848_2.png) [@Adesh\_Agarwal](https://discuss.elastic.co/u/Adesh_Agarwal)\
**Post date:** [March 10, 2022, 5:25am UTC](https://discuss.elastic.co/t/elasticsearch-failure-sink-always-running/299293/1 "2022-03-10T05:25:34Z")

</div>

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

```auto
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

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [March 10, 2022, 5:33am UTC](https://discuss.elastic.co/t/elasticsearch-failure-sink-always-running/299293/2 "2022-03-10T05:33:34Z")

</div>

Welcome to our community! 😃

Are you asking how to do this for serilog? If that's the case you might need to ask the developers there, I don't know if Elastic has expertise in that library. Otherwise, someone else might, and may stop by to help.

---

<div class="post-metadata">

**Author:** ![Adesh\_Agarwal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adesh_agarwal/32/102848_2.png) [@Adesh\_Agarwal](https://discuss.elastic.co/u/Adesh_Agarwal)\
**Post date:** [March 10, 2022, 7:22am UTC](https://discuss.elastic.co/t/elasticsearch-failure-sink-always-running/299293/3 "2022-03-10T07:22:17Z")

</div>

> [@Adesh\_Agarwal](#):
>
> 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

How do we configure FailureSink to write to local Files when Elastic Search fails to accept the events?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 7, 2022, 7:22am UTC](https://discuss.elastic.co/t/elasticsearch-failure-sink-always-running/299293/4 "2022-04-07T07:22:26Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
