serilog-sinks-applicationinsights icon indicating copy to clipboard operation
serilog-sinks-applicationinsights copied to clipboard

Azure Function Integration of Serilog with Application Insights, logs visible in Search but are not appearing in Failures events timeline

Open AhmedUzair opened this issue 4 years ago • 1 comments

Hi, I am trying to use Serilog with Application Insights sink for logging purposes. I can see the logs in Search bar in Azure Portal (Application Insights) but same logs are not visible if we view the timeline of events in Failures or Performance Tab. Thanks

Below is the code am using for registering Logger in FunctionStartup, which then gets injected in Function for logging:

var logger = new LoggerConfiguration()
                               .Enrich.FromLogContext()
                               .Enrich.WithProperty("ApplicationName", "testApp")
                               .Enrich.WithProperty("Environment", "Dev")                               
                               .WriteTo.ApplicationInsights(GetTelemetryClient("Instrumentationkey"), TelemetryConverter.Traces)
                               .CreateLogger();
builder.Services.AddSingleton<ILogger>(logger);

Telementory Client is getting fetched from a helper method:

public static TelemetryClient GetTelemetryClient(string key)
        {
            var teleConfig = new TelemetryConfiguration { InstrumentationKey = key };

            var teleClient = new TelemetryClient(teleConfig);

            return teleClient;
        }

host.json

{
    "version": "2.0",
    "logging": {
        "applicationInsights": {
            "samplingExcludedTypes": "Request",
            "samplingSettings": {
                "isEnabled": true
            }
        }
    }
}

AhmedUzair avatar May 31 '21 08:05 AhmedUzair

Hi! This one needs some investigation - it's likely there's a way to mark events as failures that we're not taking advantage of here. Marking up-for-grabs in case someone has time to investigate more thoroughly and propose a solution.

nblumhardt avatar May 01 '22 23:05 nblumhardt