从serilog.sinks.sinks.applicationinsights v3.1升级到v4.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时,我会得到此例外:
请帮助。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,我只是花了很多时间来调试此问题,因为我也遇到了这个问题。我承认我应该查看应用程序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 isSerilog.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter
as shown in the commit I linked.Hope this helps