ElasticSearch:故障接收器始终运行

发布于 2025-01-13 01:06:32 字数 1079 浏览 0 评论 0原文

日志始终会写入 Elastic Search 和本地日志文件(当用作故障接收器时)。情况不应该如此。仅当应用程序无法将日志写入 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();

SelfLog 错误: 对 Elasticsearch 执行批量操作时捕获异常:Elasticsearch.Net.ElasticsearchClientException:无法建立连接,因为目标计算机主动拒绝。呼叫:状态代码未知来自:POST /_bulk ---> System.Net.Http.HttpRequestException: 无法建立连接,因为目标机器主动拒绝它 ---> System.Net.Sockets.SocketException:无法建立连接,因为目标机器主动拒绝

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文