0
amontalvo created
1 Answer(s)
-
0
Hi amontalvo
Install the
Microsoft.ApplicationInsights.AspNetCore
package in your project. Add the Instrumentation Key from your Azure Application Insights resource to the appsettings.json file. Application Insights by adding services.AddApplicationInsightsTelemetry() in the ConfigureServices method. Your existing ILogger setup will automatically send logs to Application Insights.Example:
appsettings.json
{ "ApplicationInsights": { "InstrumentationKey": "YOUR_INSTRUMENTATION_KEY" } }
Startup.cs
public void ConfigureServices(IServiceCollection services) { //... services.AddApplicationInsightsTelemetry(Configuration["ApplicationInsights:InstrumentationKey"]); //... }
You can configure it this way if you only want to send error logs
"Logging": { "ApplicationInsights": { "LogLevel": { "Default": "Error" } } },