Azure Function无法绑定ILogger [英] Azure Function fails to bind ILogger

查看:63
本文介绍了Azure Function无法绑定ILogger的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的函数引用的程序集引用了Microsoft.Extensions.Logging.Abstractions 2.0.0。如果我在该函数的程序集中添加对该版本的nuget引用,函数执行将失败,并显示以下信息:

My function is referencing an assembly that references Microsoft.Extensions.Logging.Abstractions 2.0.0. If I add a nuget reference to that version to the function's assembly, function execution fails with:


[1/25/2018 11:14 :46 PM] Microsoft.Azure.WebJobs.Host:索引
方法 TrainingFunction.Run时出错。 Microsoft.Azure.WebJobs.Host:无法
绑定参数 log键入ILogger。确保绑定支持参数类型为
。如果您使用绑定扩展(例如
ServiceBus,Timer等),请确保已在启动代码中调用了扩展的注册
方法(例如
config .UseServiceBus(),config.UseTimers()等。)

[1/25/2018 11:14:46 PM] Microsoft.Azure.WebJobs.Host: Error indexing method 'TrainingFunction.Run'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'log' to type ILogger. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).

是否可以在Azure函数中使用较新的记录器?
(SDK 1.0.7)

Is it possible to use the newer logger in Azure functions ? (SDK 1.0.7)

推荐答案

可能发生的情况是,SDK已绑定到X的ILogger程序集和您的用户代码已绑定到版本Y。然后,绑定引擎无法将您的参数类型识别为相同,因为它们来自不同的程序集。 (这也可能发生在任何其他类型上)。

What is probably happening is that the SDK is binding to version X of the ILogger assembly and your user code is binding to version Y. The binding engine then doesn't recognize your parameter's type as being the same since they're from different assemblies. (this can happen with any other type too).

通常的解决方法是:


  1. 请参阅SDK

  2. 使用这些现有引用,不要添加具有不同版本的相同dll。

这篇关于Azure Function无法绑定ILogger的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆