I have created a Web App in Azure and a Web API in .Net core framework following the instructions in this link.
Now in my Web App , Application Insights is enabled.
In WebAPI has some similar code for logging.
public class Startup
{
public Startup()
{
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
var logger = loggerFactory.CreateLogger<ConsoleLogger>();
logger.LogInformation("Executing Configure()");
}
}
public class HomeController : Controller
{
ILogger _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
public IActionResult Index()
{
_logger.LogInformation("Executing Home/Index")
return View();
}
}
By default, it is printing some trace logs something like similar in Application Insights.
2019-01-02T07:22:49 Executing Home/Index
2019-01-02T07:22:49 Executing ObjectResult, writing value Microsoft.AspNetCore.Mvc.ControllerContext.
2019-01-02T07:22:50 Executed action [SomeActionName] (APIName) in 6487.7982ms
2019-01-02T07:22:50 Request finished in 6917.8019ms 200 application/json; charset=utf-8
Now my requirement is it should not print all the default logs in Application Insights. It has to print only those with _logger.LogInformation
. How and where do I disable this feature?