<i id='1P749'><tr id='1P749'><dt id='1P749'><q id='1P749'><span id='1P749'><b id='1P749'><form id='1P749'><ins id='1P749'></ins><ul id='1P749'></ul><sub id='1P749'></sub></form><legend id='1P749'></legend><bdo id='1P749'><pre id='1P749'><center id='1P749'></center></pre></bdo></b><th id='1P749'></th></span></q></dt></tr></i><div id='1P749'><tfoot id='1P749'></tfoot><dl id='1P749'><fieldset id='1P749'></fieldset></dl></div>
        <bdo id='1P749'></bdo><ul id='1P749'></ul>
      <legend id='1P749'><style id='1P749'><dir id='1P749'><q id='1P749'></q></dir></style></legend>
    1. <small id='1P749'></small><noframes id='1P749'>

      1. <tfoot id='1P749'></tfoot>

        不接受 Azure 函数(ILogger 或 TraceWriter)的最后一个日志记录参数

        时间:2023-10-25

          <tbody id='kLoGZ'></tbody>
      2. <i id='kLoGZ'><tr id='kLoGZ'><dt id='kLoGZ'><q id='kLoGZ'><span id='kLoGZ'><b id='kLoGZ'><form id='kLoGZ'><ins id='kLoGZ'></ins><ul id='kLoGZ'></ul><sub id='kLoGZ'></sub></form><legend id='kLoGZ'></legend><bdo id='kLoGZ'><pre id='kLoGZ'><center id='kLoGZ'></center></pre></bdo></b><th id='kLoGZ'></th></span></q></dt></tr></i><div id='kLoGZ'><tfoot id='kLoGZ'></tfoot><dl id='kLoGZ'><fieldset id='kLoGZ'></fieldset></dl></div>
          • <small id='kLoGZ'></small><noframes id='kLoGZ'>

              <bdo id='kLoGZ'></bdo><ul id='kLoGZ'></ul>

                <tfoot id='kLoGZ'></tfoot><legend id='kLoGZ'><style id='kLoGZ'><dir id='kLoGZ'><q id='kLoGZ'></q></dir></style></legend>

                1. 本文介绍了不接受 Azure 函数(ILogger 或 TraceWriter)的最后一个日志记录参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  将我自己的项目从早期(几个月前)版本的 Azure Functions 升级到当前版本后,从 VS 启动时出现以下错误.

                  After upgrading my own project from an earlier (a few months back) version of Azure Functions to current, I get the following error upon launching from VS.

                  GetLoginUrl:Microsoft.Azure.WebJobs.Host:索引方法Login.GetLoginUrl"出错.Microsoft.Azure.WebJobs.Host:无法将参数日志"绑定到 ILogger 类型.确保绑定支持参数类型.如果您使用绑定扩展(例如 ServiceBus、Timers 等),请确保您已在启动代码中调用了扩展的注册方法(例如 config.UseServiceBus()、config.UseTimers() 等.).

                  GetLoginUrl: Microsoft.Azure.WebJobs.Host: Error indexing method 'Login.GetLoginUrl'. 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.).

                  以前,我曾经将 TraceWriter log 作为方法的最后一个参数,但后来我发现我应该改用 ILogger.在进行更改之前,我遇到了与上述相同的错误.

                  Before, I used to have TraceWriter log as the last parameter to my methods but then I found out I should be using ILogger instead. Before I made the change, I was getting the same error as above.

                  ILogger 似乎映射到程序集 Microsoft.Extensions.Logging.Abstractions.也许这就是它不被识别的原因?应该使用哪个ILogger?这是方法签名.

                  The ILogger seems to be mapped to assembly Microsoft.Extensions.Logging.Abstractions. Perhaps this is why it is not recognized? Which ILogger should be used? Here is the method signature.

                  [FunctionName("GetLoginUrl")]
                  public static HttpResponseMessage GetLoginUrl(
                      [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)]HttpRequestMessage req,
                      ILogger log)
                  

                  我没有尝试将其部署到 Azure.

                  I did not try to deploy this to Azure.

                  很遗憾,创建一个全新的 Functions 项目并没有帮助,因为没有 .CS 文件可供查找以纠正此问题.

                  Unfortunately, creating a brand new Functions project does not help as there are no .CS files to look up to in order to correct this.

                  推荐答案

                  Microsoft.Extensions.Logging.Abstractions 是正确的程序集.

                  您可能直接引用了一些较旧的 NuGet 包(例如 Microsoft.Azure.WebJobs).如果是这样,请务必将其删除.除非您使用一些额外的绑定,否则您的 csproj 引用应该看起来像这样简单:

                  You are probably referencing some older NuGet packages directly (e.g. Microsoft.Azure.WebJobs). If so, be sure to remove it. Unless you are using some additional binding, your csproj references should look as simple as this:

                  <ItemGroup>           
                      <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.4" />
                  </ItemGroup>
                  

                  这篇关于不接受 Azure 函数(ILogger 或 TraceWriter)的最后一个日志记录参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在 Azure Function 的自定义 HTTP 路由中指定查询参数? 下一篇:Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发

                  相关文章

                2. <small id='U4RwC'></small><noframes id='U4RwC'>

                  <legend id='U4RwC'><style id='U4RwC'><dir id='U4RwC'><q id='U4RwC'></q></dir></style></legend>
                3. <tfoot id='U4RwC'></tfoot>

                      <bdo id='U4RwC'></bdo><ul id='U4RwC'></ul>
                  1. <i id='U4RwC'><tr id='U4RwC'><dt id='U4RwC'><q id='U4RwC'><span id='U4RwC'><b id='U4RwC'><form id='U4RwC'><ins id='U4RwC'></ins><ul id='U4RwC'></ul><sub id='U4RwC'></sub></form><legend id='U4RwC'></legend><bdo id='U4RwC'><pre id='U4RwC'><center id='U4RwC'></center></pre></bdo></b><th id='U4RwC'></th></span></q></dt></tr></i><div id='U4RwC'><tfoot id='U4RwC'></tfoot><dl id='U4RwC'><fieldset id='U4RwC'></fieldset></dl></div>