Skip to content

Application of logging severity is inconsistent with documentation #674

Open
@jimblanchard-ms

Description

@jimblanchard-ms

We are using the App Settings dialog to manage log levels for Azure Functions. According to https://learn.microsoft.com/en-us/azure/azure-functions/configure-monitoring?tabs=v2#configure-categories, the Host.Results setting controls logging of entries to the requests table. However, with version 4.13 of the runtime, having
AzureFunctionsJobHost__logging__logLevel__default = Warning
AzureFunctionsJobHost__logging__logLevel__Host__Results = Information
results in no request information being received by the requests table.

Investigative information

Please provide the following:

  • Timestamp: 2022-11-01T00:16:54.2729718Z
  • Function App name: com-foo-bar-20220830131408475
  • Function name(s) (as appropriate): Functions.HttpExample
  • Invocation ID: a8ac4748-f1c7-4a45-ac24-9b2fc92b7d9b
  • Region: West US

Repro steps

Provide the steps required to reproduce the problem:

Configure the function with the following App Settings
{
"name": "AzureFunctionsJobHost__logging__logLevel__default",
"value": "Warning",
"slotSetting": false
},
{
"name": "AzureFunctionsJobHost__logging__logLevel__Function",
"value": "Information",
"slotSetting": false
},
{
"name": "AzureFunctionsJobHost__logging__logLevel__Function.HttpExample",
"value": "Information",
"slotSetting": false
},
{
"name": "AzureFunctionsJobHost__logging__logLevel__Function.HttpExample.User",
"value": "Warning",
"slotSetting": false
},
{
"name": "AzureFunctionsJobHost__logging__logLevel__Host__Aggregator",
"value": "Information",
"slotSetting": false
},
{
"name": "AzureFunctionsJobHost__logging__logLevel__Host__Results",
"value": "Information",
"slotSetting": false
},
{
"name": "AzureFunctionsJobHost__logging__logLevel__Microsoft",
"value": "Warning",
"slotSetting": false
},
{
"name": "AzureFunctionsJobHost__logging__logLevel__Worker",
"value": "Warning",
"slotSetting": false
},

Expected behavior

When the function is triggered, an entry should appear in the Application Insights requests table.

Actual behavior

No entry appears in the requests table.

Known workarounds

Changing this setting to Information will result in the entry appearing in the Request table
{
"name": "AzureFunctionsJobHost__logging__logLevel__default",
"value": "Information",
"slotSetting": false
},

Related information

Provide any related information

  • Programming language: Java
Source
package org.example.functions;

import com.microsoft.azure.functions.ExecutionContext;
import com.microsoft.azure.functions.HttpMethod;
import com.microsoft.azure.functions.HttpRequestMessage;
import com.microsoft.azure.functions.HttpResponseMessage;
import com.microsoft.azure.functions.HttpStatus;
import com.microsoft.azure.functions.annotation.AuthorizationLevel;
import com.microsoft.azure.functions.annotation.FunctionName;
import com.microsoft.azure.functions.annotation.HttpTrigger;
import lombok.extern.slf4j.Slf4j;

import java.util.Optional;

/**
 * Azure Functions with HTTP Trigger.
 */
@Slf4j
public class HttpTriggerFunction {
    /**
     * This function listens at endpoint "/api/HttpExample". Two ways to invoke it using "curl" command in bash:
     * 1. curl -d "HTTP Body" {your host}/api/HttpExample
     * 2. curl "{your host}/api/HttpExample?name=HTTP%20Query"
     */
    @FunctionName("HttpExample")
    public HttpResponseMessage run(
            @HttpTrigger(
                name = "req",
                methods = {HttpMethod.GET, HttpMethod.POST},
                authLevel = AuthorizationLevel.ANONYMOUS)
                HttpRequestMessage<Optional<String>> request,
            final ExecutionContext context) {
        context.getLogger().info("2 Java HTTP trigger processed a request.");

        // Parse query parameter
        final String query = request.getQueryParameters().get("name");
        final String name = request.getBody().orElse(query);

        log.error("Error Log");
        log.warn("Warning Log");
        log.info("Info Log");
        log.debug("Debug Log");
        log.trace("Trace Log");

        if (name == null) {
            return request.createResponseBuilder(HttpStatus.BAD_REQUEST).body("Please pass a name on the query string or in the request body").build();
        } else {
            return request.createResponseBuilder(HttpStatus.OK).body("Hello, " + name).build();
        }
    }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions