There are a few similar questions but none have really answered my question. I'm wanting to use Ilogger to log my custom user logs but still keep the Visual Studio "auto" added Application insights. This is pretty straight forward in .Net core (just add the Ilogger in startup) but .Net Framework not so much (unless I'm missing something?). Maybe I'm going about this wrong?
I'm, wondering if anyone has this working or am I wasting my time and should just use TelemetryClient directly?
I have 2 old ASP.Net Framework 4.8 Apis, Both deployed to an Azure App service.
app# 1 has had Application Insights added to it by the auto way in Visual studio at some point in the past. It logs telemetry fine, but when I added Ilogger to it, it doesn't log any of the user logs.
app#2 I have working with ILogger only and logging all the logs I create, but no auto logging of anything and no telemetry (haven't tried adding it yet due to app #1 not working).
Both use Autofac for dependency injection, which has an extension to allow you to use Microsoft.Extensions.dependency injection with it. Like this:
var builder = new ContainerBuilder();
IServiceCollection services = new ServiceCollection();
services.AddLogging(options =>
{
options.AddApplicationInsights(configureTelemetryConfiguration: (c) => c.ConnectionString = ConfigurationManager.AppSettings["APPLICATIONINSIGHTS_CONNECTION_STRING"],
configureApplicationInsightsLoggerOptions: (o) =>{});
});
builder.Populate(services);
App #2 this works fine, everything I create logs.
App#1 Has the following packages installed and a huge amount of stuff in applicationInsights.config and logs telemetry but seems to ignore any of my created logs
<package id="Microsoft.ApplicationInsights" version="2.22.0" targetFramework="net48" />
<package id="Microsoft.ApplicationInsights.Agent.Intercept" version="2.4.0" targetFramework="net48" />
<package id="Microsoft.ApplicationInsights.DependencyCollector" version="2.22.0" targetFramework="net48" />
<package id="Microsoft.ApplicationInsights.PerfCounterCollector" version="2.22.0" targetFramework="net48" />
<package id="Microsoft.ApplicationInsights.TraceListener" version="2.22.0" targetFramework="net48" />
<package id="Microsoft.ApplicationInsights.Web" version="2.22.0" targetFramework="net48" />
<package id="Microsoft.ApplicationInsights.WindowsServer" version="2.22.0" targetFramework="net48" />
<package id="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" version="2.22.0" targetFramework="net48" />
Any ideas?
I do have filtering all set up properly, so it's not filtering out the user logs. Even tried just putting in Logging:LogLevel:default = Trace
I ended up removing all application insights and logging completely and re-doing them and now it works perfectly.. Must have messed something up or maybe the very old setup of application insights was not compatible