我有一个 ASP.NET Core Web 项目部署到 Azure 并配置了 Application Insights。Insights 可以正常接收请求等数据,但我无法让它显示我的日志。
我正在使用 vanilla Microsoft.Extensions.Logging 框架,并且在控制器操作上记录了一个测试错误
logger.LogError("Test application insights message");
在我设置的 Startup.cs 配置方法中
loggerFactory.AddAzureWebAppDiagnostics();
...并且可以成功看到错误消息出现在 Azure 日志流中:
2017-04-14 11:06:00.313 +00:00 [Error] Test application insights message
但是,我也希望此消息出现在 Application Insights 跟踪中,但无处可寻。我想我需要配置 ILoggerFactory 但不确定如何并且找不到有关该主题的任何文档。
在此先感谢您的帮助