1

I added logging through opentelemetry and now I am getting duplicated entries of logs as they are sent through both Function's handler and opentelemetry handler.

I want to disable Function logging as opentelemetry adds tracer span awareness through OperationID/ParentID, thus making opentelemetry logs more functional with correlation. It is necessary to disable Function's logging in an individual function at this point, as the rest functions are not instrumented yet.

According to this document, I must be able to set environment variables like

AzureFunctionsJobHost__logging__logLevel__Function__MyFunction__User

to control logging while overriding other settings. I found that host-level setting like

AzureFunctionsJobHost__logging__logLevel__Function=None

does work, essentially disabling all logging, but on individual function level (with __MyFunction__User suffix) this setting is ignored.

I also noticed that settings through host.json work, too:

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    },
    "logLevel": {
      "Function": "Information",
      "Function.MyFunction.User": "None"
    }
  }
}

The above achieves the goal, but configuring through env vars is preferred for me. What am I missing?

2 Answers 2

0

I tried using both the settings below and the Logging was disabled only when I added the Log level to None for the individual Function in host.json and after adding the setting in Environment variables it did not work.

Environment Settings: -

"name": "AzureFunctionsJobHost__logging__logLevel__Function__http_trigger__User",
"value": "None",
"name": "AzureFunctionsJobHost__logging__logLevel__Function__http_trigger",
"value": "None",

host.json:-

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

The Function Logs were still visible: -

enter image description here

But when I added loglevel setting at host.json to None, The Function trigger Logs were disabled: -

host.json:-

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

Output: -

enter image description here

This looks like a Bug. I have raised a Github Issue on the same to make this Setting work, Follow this issue for the further updates.

Sign up to request clarification or add additional context in comments.

Comments

0

Also noted on the corresponding GitHub issue -- the issue here was your syntax in mapping to values:

The values you want to set are: AzureFunctionsJobHost__logging__logLevel__Function.http_trigger.User AzureFunctionsJobHost__logging__logLevel__Function.http_trigger

The key is that underscores map to object traversal within host.json.

Values like Function.http_trigger.User are just strings, so there's no need to replace the periods with underscores.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.