【发布时间】:2018-03-21 02:01:52
【问题描述】:
我正在 Visual Studio 2017 中编写一个 ASP.NET Core 2.0 应用程序。我已经像这样登录控制器:
public HomeController(ILogger<HomeController> logger)
{
this._logger = logger;
}
public IActionResult Index()
{
_logger.LogInformation("In The Index");
return View();
}
这在调试窗口中生成日志就好了:
WebApplication4.Controllers.HomeController:信息:在索引中
但是,我想不记录所有这些遥测方法:
Application Insights 遥测(未配置):{"name":"Microsoft.ApplicationInsights.Dev.Message","time":"2017-10-09T19:11:31.1311753Z","tags":{"ai. internal.nodeName":"DESKTOP-MBRK754","ai.operation.id":"7a80811a-422cb8019de22af6","ai.location.ip":"127.0.0.1","ai.cloud.roleInstance":"DESKTOP- MBRK754","ai.operation.parentId":"|7a80811a-422cb8019de22af6.","ai.application.ver":"1.0.0.0","ai.operation.name":"GET Home/Index","ai .internal.sdkVersion":"aspnet5c:2.1.1"},"data":{"baseType":"MessageData","baseData":{"ver":2,"message":"执行动作方法 WebApplication4.Controllers .HomeController.Index (WebApplication4) 带参数 ((null)) - ModelState 有效","severityLevel":"Information","properties":{"AspNetCoreEnvironment":"Development","ValidationState":"Valid"," ActionName":"WebApplication4.Controllers.HomeController.Index (WebApplication4)","CategoryName":"Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker","DeveloperMode":"true","{OriginalFormat}":"执行动作我thod {ActionName} 带参数 ({Arguments}) - ModelState 是 {ValidationState}"}}}}
我的 appsettings.json 看起来像这样:
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Information"
}
}
如何过滤仅遥测消息?
【问题讨论】:
标签: azure-application-insights asp.net-core-2.0 .net-core-2.0