如何让 Logger.BeginScope 与 Application Insights 配合使用?

jsk*_*jsk 5 logging azure-application-insights asp.net-core asp.net-core-2.0

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

using (_logger.BeginScope("Some really useful information"))
{
    // something something

    _logger.LogError("Oh no.");
}
Run Code Online (Sandbox Code Playgroud)

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

jsk*_*jsk 3

我通过使用 Serilog 及其 Application Insights 接收器解决了这个问题。效果很好。