forsmyr
forsmyr

Reputation: 314

Serilog configuration and Application Insight .net core

Im trying to filter my input to application insight by configuration. Im sending data from SeriLog with the ApplicationInsightsTraces-sink as can be seen below in my configuration:

        Log.Logger = new LoggerConfiguration()
            .ReadFrom.Configuration(Configuration)
            .WriteTo
            .ApplicationInsightsTraces(Configuration.GetSection("ApplicationInsights")
                .GetSection("InstrumentationKey").Value)
            .CreateLogger();

This code sends the correct data to the "Trace" in Application Insights but AI gets the traces from somewhere else also. I guess the framework in some way? I would like to turn off the standard logging of traces from the framework so that I can use only one filter for what to log (loglevel and specific overrides for example "Microsoft.AspNetCore": "Warning". I would prefer to not filter in a processor for each Trace. Any ideas?

Upvotes: 1

Views: 2620

Answers (1)

forsmyr
forsmyr

Reputation: 314

It seems to be working the way I want it to when I reset the options object by row provided below. Im not exactly sure which property in ApplicationInsightsServiceOptions that did the change.

services.Configure<ApplicationInsightsServiceOptions>(
    options => Configuration.GetSection("applicationInsights").Bind(options));

Upvotes: 1

Related Questions