We're trying to get Application Insights enabled for our ASP Net Core 7.0 C# application. We've used a few sources, including this Microsoft site:
The Azure Application Insights module itself seem correctly configured, for example it's showing app requests correctly.
However our custom ILogger messages in our C# application don't show up in the Azure App Insights traces
section.
We've based our setup below from various other examples on how to configure ILogging, so we're not sure which aspect of our setup is wrong, but suspect it's in our code somewhere.
C# Program
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
...
builder.Services.AddApplicationInsightsTelemetry();
builder.Logging.AddApplicationInsights(
configureTelemetryConfiguration: config =>
config.ConnectionString = configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"],
configureApplicationInsightsLoggerOptions: options => { }
);
...
var app = builder.Build();
}
appsettings.json
Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"ApplicationInsights": "Debug"
}
}
csproj file
<ItemGroup>
...
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
...
</ItemGroup>