I am trying to write logs to the Azure application but It's not writing the all logs. There are no errors or exceptions. Please help. I have referred to this document.
I have made the below changes.
Just created the Web API project from VS 2022 targeting to .Net 6.
Added the below line to the default templated code.
builder.Services.AddApplicationInsightsTelemetry();
Added the below to appsettings.json.
"ApplicationInsights": {
"ConnectionString": "MyConnectionString"
}
Added these logs.
_logger.LogInformation("VivekLogInformation");
_logger.LogTrace("VivekLogTrace");
_logger.LogCritical("VivekLogCritical");
_logger.LogDebug("VivekLogDebug");
_logger.LogWarning("VivekLogWarningn");
Run the application and call the action method.
I have tried to run the below query to check the logs.
traces
| where message contains "Vivek"
Note: This is my first time trying to write to application insights.
I am able to see logs by adding these lines. But it only writes VivekLogWarningn and VivekLogCritical in logs. I have tried changing the Default LogLevel to Debug as well. But it's not writing all logs.
builder.Services.AddLogging(builder =>
{
builder.AddApplicationInsights();
});
I have tried this now.
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft.AspNetCore": "Debug"
}
}