覆盖功能日志级别不起作用

问题描述 投票:0回答:1

我有一个带有 HTTP 触发器(Java,运行时版本 ~4)的 Azure 函数,并且想要覆盖此特定函数的日志记录级别:

@FunctionName("Stores")
public HttpResponseMessage getStores(
            @HttpTrigger(...
...
    context.getLogger().log(Level.FINE, "Test message with level " + Level.FINE);
...

我可以在 host.json 中设置特定于功能的日志级别,这工作正常(本地 在云中):

  "logging": {
    "logLevel": {
      "Function.Stores.User": "Trace"
    }
  }

当我使用以下语法时,覆盖

local.settings.json
中的日志级别效果很好:

"AzureFunctionsJobHost__logging__logLevel__Function.Stores.User": "Trace"

请注意,我不能用双下划线替换

Function.Stores.User
部分中的点,如https://learn.microsoft.com/en-us/azure/azure-functions/configure-monitoring? 中所述?选项卡=v2。文档中的这部分似乎是错误的。

但是当我将具有值

AzureFunctionsJobHost__logging__logLevel__Function.Stores.User
的设置
Trace
添加到云门户中的应用程序设置时,它没有任何效果。

这是一个错误还是我的设置有问题?

azure-functions
1个回答
0
投票

不能用双下划线替换部分

Function.Stores.User
中的点,如记录的那样

您应该能够通过创建具有特定格式的等效应用程序设置来覆盖 host.json 值。

  • host.json 路径中的点确实应该替换为双下划线。
  1. Host.json路径

    logging.logLevel.default

    • 应用程序设置
      AzureFunctionsJobHost__logging__logLevel__default
  2. Host.json路径

    logging.logLevel.Host.Aggregator

    • 应用程序设置
      AzureFunctionsJobHost__logging__logLevel__Host__Aggregator
  3. Host.json路径

    logging.logLevel.Function

    • 应用程序设置
      AzureFunctionsJobHost__logging__logLevel__Function
  4. Host.json路径

    logging.logLevel.Function.Function1

    • 应用程序设置
      AzureFunctionsJobHost__logging__logLevel__Function__Function1
  5. Host.json路径

    logging.logLevel.Function.Function1.User

    • 应用程序设置
      AzureFunctionsJobHost__logging__logLevel__Function__Function1__User

您提供的上述设置没有明显问题。 Azure Functions 环境中可能存在错误问题或意外行为。

  • 检查这个SO链接,我已经浏览过该链接,与您的要求类似。

我尝试过以下设置。

主机.json

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    },
    "logLevel": {
      "Function": "Error",
      "Function_http_trigger": "Information"
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[4.*, 5.0.0)"
  }
}

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.