Reputation: 101
I am trying to configure Logging for my .NET 6 Blazor server application. In the past it has not been an issue for me, but now I can not see any Traces logs on Azure. I have been followring these qusetions:
Application Insights' Logs Not Writing to Traces Log
ILogger Logging Doesn't Show Up in Azure Application Insights
Moreover I have followed the documentation here:
Application Insights logging with .NET
Application Insights for ASP.NET Core applications
Migrate from Application Insights instrumentation keys to connection strings
Sampling in Application Insights
The code
AppSettings
"Logging": {
"LogLevel": {
"Default": "Warning"
},
"ApplicationInsights": {
"LogLevel": {
"Default": "Warning"
}
}
},
"ApplicationInsights": {
"ConnectionString": "
InstrumentationKey=Here i put the InstrumentationKey ofc. ;IngestionEndpoint=https://northeurope2.in.applicationinsights.azure.com/
;LiveEndpoint=https://northeurope.livediagnostics.monitor.azure.com/"
},
Program.cs
var options = new ApplicationInsightsServiceOptions { ConnectionString = configuration["ApplicationInsights:ConnectionString"] };
builder.Services.AddApplicationInsightsTelemetry(options);
The razor.cs page
[Inject]
public ILogger<NailOtherSingelShearTimberTimber> Logger { get; set; }
public async Task SaveFile()
{
Logger.LogWarning("File saved");
}
If i run it locally I can see it is being sent...
But I get nothing on Azure no matter how long i wait.
And Data sampling is set to 100%
Does anyone know what I am doing wrong?
Upvotes: 2
Views: 4265
Reputation: 101
After two days without any success I decided to delete the web app + resource group and created a new web app. Then I updated the connection string in AppSettings, published the application and now logging works like a charm.
Upvotes: 1