【发布时间】:2020-02-18 16:42:36
【问题描述】:
我有一个 .NET Core WebAPI 应用程序。该应用作为应用服务部署在 Azure 上。
在代码中,我像这样启用了 Application Insights
public static IWebHost BuildWebHost(string[] args) =>
WebHost
.CreateDefaultBuilder(args)
.UseApplicationInsights()
.UseStartup<Startup>()
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging")).SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Error);
logging.AddApplicationInsights(" xxxxx-xxxx-xxxx-xxxx--xxxxxxxxxxx").SetMinimumLevel(LogLevel.Trace);
})
.Build();
在控制器的构造函数和控制器的方法中,我有这些日志记录语句。
_logger.LogInformation("ApiController, information");
_logger.LogWarning("ApiController, warning");
_logger.LogCritical("ApiController, critical");
_logger.LogWarning("ApiController, error");
_logger.LogDebug("ApiController, debug");
在 Azure 门户中,我为我的应用服务启用了 Application Insights。这是来自门户的图片。
但是我在 Azure 门户中的哪里可以看到日志记录语句?
当我转到Application Insights -> Logs 并查询时
search *
我可以看到对 API 的请求,但看不到日志语句。
日志语句在哪里?
【问题讨论】:
-
您好,如果回答有帮助,请帮忙accept it as answer,谢谢。
标签: azure logging .net-core azure-application-insights webapi