1

I'm using Serilog in an Azure Worker Role & a WebApi with the ElasticSearch sink.

Everything works fine on the Worker Role.

On the WebApi I tried the Trace & Email sinks and they work fine. ElasticSearch sink is not logging at all.

Here is my configuration:

var logger = new LoggerConfiguration()
                   .MinimumLevel.Information()
                   .WriteTo.Trace()
                   .WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri("https://myElasticServer")))
                   .CreateLogger();

If I try to write Logs in a controller, I have them in the Trace but nothing in Trace.

1 Answer 1

2

The problem came from a self signed certificate.

I've created my own CertificateValidation method to ignore certificate validation based on an exclusion list

private bool MyCertificateValidationCallback(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
    if (sslPolicyErrors == SslPolicyErrors.None)
        return true;

    var request = sender as HttpWebRequest;

    if (request != null)
    {
        var exclusion = ConfigurationManager.AppSettings["CertificateExclusion"];

        if (exclusion.Contains(request.Host))
            return true;
    }

    return false;
}

And register it when the application starts

ServicePointManager.ServerCertificateValidationCallback = MyCertificateValidationCallback;
Sign up to request clarification or add additional context in comments.

2 Comments

Hi, i'm having the same problem could you please elaborate what have you entered for CertificateExclusion config settings
I don't have this code anymore, but it should be something like CertificationExclusion="mydomain.com"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.