serilog-contrib / serilog-sinks-elasticsearch

A Serilog sink that writes events to Elasticsearch
Apache License 2.0
434 stars 197 forks source link

Elasticsearch Sink Does Not Report Errors to the Selflog. #341

Open estoces opened 4 years ago

estoces commented 4 years ago

A few questions before you begin:

Is this an issue related to the Serilog core project or one of the [sinks]

Serilog Elasticsearch Sink issue

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

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

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

Please describe the current behavior? Sink does not publish log entries to ElasticCloud/Kibana. SelfLog (console) is not outputting any issues.

Please describe the expected behavior? Errors would be reported to the SelfLog and written to the console if failure occurred when sending data to Elasticsearch/Kibana.

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

I updated to 8.1.0 and log entries started failing to get to kibana. Ran locally to reproduce. No errors were being written to the console. Selflog was enables e.g. SelfLog.Enable(Console.Out);

Reverted back to 8.0.1 and ran and everything was good. Changed index to something invalid to see if the SelfLog would output errors. The log entries failed to make it to kibana and no error was reported to SelfLog.

suadev commented 4 years ago

Same here.

nibro7778 commented 3 years ago

For me, it's not working even with 8.0.1. I am using it in the net core 3.1 version

return logs.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(uri)
            {
                FailureCallback = e => System.Console.WriteLine($"Unable to send logs to elasticsearch: {e.MessageTemplate} {e.Exception.Message} "),
                EmitEventFailure = EmitEventFailureHandling.RaiseCallback,
                AutoRegisterTemplate = true,
                AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv7,                
                IndexFormat = index,
                MinimumLogEventLevel = level
            });

I have added FailureCallback and also enable SelfLog.Enable(Console.WriteLine);

@estoces do you think I am missing something or is it because not compatible with .netcore 3.1?