如何让Logger.BeginScope与Application Insights一起使用?

时间:2018-02-01 11:42:38

标签: logging asp.net-core asp.net-core-2.0 azure-application-insights

我已经在某处读过Application Insights应该使用结构化日志,并且我尝试使用ILogger的BeginScope将数据记录到Application Insights:

static navigationOptions = {
  drawerLockMode: 'locked-closed'
}

但是,在检查Application Insights中的跟踪时,我没有从BeginScope获取日志数据,只是"哦没有"在这种情况下。 这是一个.NET Core 2.0应用程序。 Application Insights ILogger的默认实现是否不支持BeginScope?或者我错过了什么?

编辑: 我通过使用Serilog和它的Application Insights接收器解决了这个问题。 工作得很好。

2 个答案:

答案 0 :(得分:1)

我通过将Serilog与它的Application Insights接收器一起使用来解决此问题。效果很好。

答案 1 :(得分:0)

Application Insights尚不直接支持'Scopes',但是在功能积压中。 https://github.com/Microsoft/ApplicationInsights-aspnetcore/issues/491