从serilog.sinks.sinks.applicationinsights v3.1升级到v4.0时会出现错误

发布于 2025-02-10 06:18:30 字数 1531 浏览 2 评论 0 原文

我有一个Azure函数,它使用serilog用

startup.cs 中的代码看起来像这样

Log.Logger = new LoggerConfiguration()
            .ReadFrom.Configuration(config)
            .CreateLogger();

appsettings.json

"Serilog": {
    "Using": [
      "Serilog.Sinks.ApplicationInsights"
    ],
    "WriteTo": [
      {
        "Name": "ApplicationInsights",
        "Args": {
          "instrumentationKey": "...",
          "restrictedToMinimumLevel": "Verbose",
          "telemetryConverter": "Serilog.Sinks.ApplicationInsights.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights"
      }
    }
  ],
  ...

它可以愉快地将应用程序日志写入AppInsights。

最新的github 文档提到了遥测配置的贬低和对 instrumentation键的未来拆卸支持,因此我想将库将库升级到版本4.0。

但是,当我升级到v4.0时,我会得到此例外:

”在此处输入图像描述

请帮助。

I have an Azure Function that uses Serilog to write to AppInsights with Serilog AppInsights sink v3.1.

The code in Startup.cs looks like this

Log.Logger = new LoggerConfiguration()
            .ReadFrom.Configuration(config)
            .CreateLogger();

and appsettings.json

"Serilog": {
    "Using": [
      "Serilog.Sinks.ApplicationInsights"
    ],
    "WriteTo": [
      {
        "Name": "ApplicationInsights",
        "Args": {
          "instrumentationKey": "...",
          "restrictedToMinimumLevel": "Verbose",
          "telemetryConverter": "Serilog.Sinks.ApplicationInsights.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights"
      }
    }
  ],
  ...

It can happily write application logs into AppInsights.

The latest Github documentation mentioned the deprecation of telemetry configuration active and future removal support of Instrumentation Key therefore I would like to upgrade the library to version 4.0.

However, when I upgrade to the sink to v4.0, I get this exception:

enter image description here

Please help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜柠檬 2025-02-17 06:18:31

因此,我只是花了很多时间来调试此问题,因为我也遇到了这个问题。我承认我应该查看应用程序Insights sink的git日志,因为有问题的提交在这里

https://github.com/serilog-contrib/serilog-sinks-applicationinsights/commit/8e4e26a8fdfa12da6ed15afcc94889e5f399ff97#diff-bc9f0e00aaa0aef88484faa764a62f13d26f07bf6c2b6df21cd8d893aa47c2e0

They adjusted their namespaces, which causes the Serilog配置绑定无法找到类型 serilog.sinks.applicationinsights.sinks.sinks.applicationinsights.telemetryconverters.traceTeleMetryConverter 。取而代之的是命名空间是 serilog.sinks.applicationinsights.telemetryconverters.traceTeleMetryConverter ,如i链接所示。

希望这会有所帮助

So I just spent a good chunk of time debugging this, because I also ran into the issue. I'll admit I should have look at the git log for the app insights sink, because the offending commit is right here

https://github.com/serilog-contrib/serilog-sinks-applicationinsights/commit/8e4e26a8fdfa12da6ed15afcc94889e5f399ff97#diff-bc9f0e00aaa0aef88484faa764a62f13d26f07bf6c2b6df21cd8d893aa47c2e0

They adjusted their namespaces, which causes the Serilog Configuration binding not to be able to find the type Serilog.Sinks.ApplicationInsights.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter anymore. Instead the namespace is Serilog.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter as shown in the commit I linked.

Hope this helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文