'Not able to get all the logs in application insights even after disabling sampling

I am generating logs for my client application where there is very limited internet connectivity. I am storing the offline logs and generating it to application insights once the user is back online. The problem I am facing is out of all the logs only request logs are coming rest are getting discarded. This is happening because of sampling even though I have already disabled the sampling from Startup.cs. Here is my code:

var aiOptions = new Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions();
    aiOptions.EnableAdaptiveSampling = false;
    services.AddApplicationInsightsTelemetry(aiOptions);

Any Suggestions how to completely remove the sampling so that I can have all the logs in application insight.



Solution 1:[1]

  • Check this document to see different log levels. if you have latest version of sdk than ILogger Can capture without required action.
  • It will capture log level. Here is the configuration of logging level.
    .ConfigureLogging(
                builder =>
                {                
                    builder.AddApplicationInsights("ikey");
      builder.AddFilter<Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider>("", LogLevel.Information); // this will capture Info level traces and above.
                }
  • For complete information check this SO thread.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SaiSakethGuduru-MT