我正在 Azure 上开发 .netcore6 网络应用程序,使用 Serilog 和 Serilog AzureInsights Sink 作为核心调试机制。我想禁用默认情况下发送到
HttpRequest
的 Azure Insights
日志记录。我在这里查看了文档https://learn.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core?tabs=netcorenew%2Cnetcore6,显然有一个配置EnableRequestTrackingTelemetryModule
会让我做到这一点。
这里的问题是我无法从
appsettings.json
配置它,最好把它放在哪里?
以下是我目前的配置供参考:
"Serilog": {
"Using": [ "Serilog.Sinks.ApplicationInsights" ],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft.AspNetCore.Hosting.Diagnostics": "Warning",
"Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware": "Warning",
"Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker": "Warning",
"Microsoft.EntityFrameworkCore.Database.Command": "Warning",
"Microsoft.AspNetCore.Routing.EndpointMiddleware": "Warning",
"Microsoft.Extensions.Http.DefaultHttpClientFactory": "Warning",
"Microsoft.AspNetCore.Server.Kestrel": "Warning",
"Microsoft.AspNetCore.Mvc.ModelBinding": "Warning",
"Microsoft.AspNetCore.Routing": "Warning"
}
},
"WriteTo": [
{
"Name": "ApplicationInsights",
"Args": {
"connectionString" : "InstrumentationKey=ff394818-38fa-4239-8cb4-3380d6812e4d;IngestionEndpoint=https://westeurope-1.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/",
"restrictedToMinimumLevel": "Information",
"telemetryConverter": "Serilog.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights",
"EnableRequestTrackingTelemetryModule": false
}
}
],
"Enrich": [ "FromLogContext" ]
}