Azure function Isolated worker - host vs worker logging config

222 views Asked by At

In the docs for the isolated worker model, it says you have to configure logging for the worker and the host separately: https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide?tabs=windows#managing-log-levels

The Functions host and the isolated process worker have separate configuration for log levels, etc. Any Application Insights configuration in host.json will not affect the logging from the worker, and similarly, configuration made in your worker code will not impact logging from the host. You need to apply changes in both places if your scenario requires customization at both layers.

That's fine, but it's unclear which logs are emitted by the host vs the worker. For example, if I'm trying to set log level for Azure.Core so that it only logs Errors, do I set that in host.json or the appsettings for my worker, or both?

1

There are 1 answers

1
Pavan On

to set log level for Azure.Core so that it only logs Errors, do I set that in host.json or the appsettings for my worker, or both?

The configuration file of worker process is appsettings.json in that to set the logging level for specific components or libraries used within the functions code. to set the logging level for the Azure.Core namespace in the worker's like below:

appsettings.json:

{
  "Logging": {
    "LogLevel": {
      "Azure.Core": "Error"
    }
  }
}
  • By this configuration Azure.Core namespace logs only the Error logs. not necessary to set the same config also in host.json.

For Azure function host set the logging levels in host.json file. To set the host logging level like below:

Host.json:

{
  "version": "2.0",
  "logging": {
    "logLevel": {
      "default": "Information"
    }
  }
}

The above configuration will ensure that the host emits logs at the "Information" level. I have refered this This for the isolated logging levels for function.