ElasticSearch:故障接收器始终运行
日志始终会写入 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论