I have an Azure Function with an HTTP Trigger (Java, Runtime Version ~4) and want to override the logging level of this specific function:
@FunctionName("Stores")
public HttpResponseMessage getStores(
@HttpTrigger(...
...
context.getLogger().log(Level.FINE, "Test message with level " + Level.FINE);
...
I can set a function-specific log level in the host.json, this works fine (locally and in the cloud):
"logging": {
"logLevel": {
"Function.Stores.User": "Trace"
}
}
Overriding the log level in the local.settings.json works fine when I use the following syntax:
"AzureFunctionsJobHost__logging__logLevel__Function.Stores.User": "Trace"
Note, that I can't replace the dots in the part Function.Stores.User with double underscores as documented in https://learn.microsoft.com/en-us/azure/azure-functions/configure-monitoring?tabs=v2. It seems that this part in the documentation is wrong.
But when I add the setting AzureFunctionsJobHost__logging__logLevel__Function.Stores.User with value Trace to the application settings in the cloud portal, it has no effect.
Is this a bug or is there anything wrong with my settings?
You should be able to override the host.json values by creating equivalent application settings with specific formatting.
Host.json path:
logging.logLevel.defaultAzureFunctionsJobHost__logging__logLevel__defaultHost.json path:
logging.logLevel.Host.AggregatorAzureFunctionsJobHost__logging__logLevel__Host__AggregatorHost.json path:
logging.logLevel.FunctionAzureFunctionsJobHost__logging__logLevel__FunctionHost.json path:
logging.logLevel.Function.Function1AzureFunctionsJobHost__logging__logLevel__Function__Function1Host.json path:
logging.logLevel.Function.Function1.UserAzureFunctionsJobHost__logging__logLevel__Function__Function1__UserThere are no apparent issues with the above settings you provided. There might be a bug issue or an unexpected behavior in the Azure Functions environment.
I have tried with these below settings.
host.json