The issue with your Azure Functions logging configuration seems to stem from how the log levels are set up in your host.json
file, especially considering the identifiers you're using to specify log levels for your functions. To resolve this and ensure that your custom log statements are being outputted as expected, follow these steps:
Ensure Correct Category Names for Logging: The category names in the logLevel
section must match the categories used in your function code. Often, these should be set to the name of the function itself or the log categories that you define within your code.
Modify host.json Configuration: Update your host.json
to make sure the log level settings are correctly targeted. Here’s a simplified way to configure it, assuming your functions are named as such in your logging configuration:
{
"version": "2.0",
"logging":
{ "logLevel": { "default": "None", // Set default log level to None to minimize internal logs "Function": "Information", // Enable Information level logs for all functions generally "Function.TimedSQSFunctionApp": "Information", "Function.QueueTriggerFuncApp": "Information", "Function.QueueManagerFunctionApp": "Information", "Function.QueueManagerFunctionApp.User": "Information"
}
}
}
import logging def main(): logging.info("some custom log") if __name__ == "__main__": main()
Verify Application Insights is Connected (if used): If you are using Application Insights, make sure it is properly connected to your Azure Functions application to track the logs.
Run and Test Locally: When running locally in Visual Studio Code, ensure that your local settings (local.settings.json
) are not overriding any host.json
settings. It should include the necessary configuration to capture logs at the desired level.
Check Console Output in VS Code: When you run the function app in VS Code, make sure the output/console window is visible and configured to show information logs. Sometimes, VS Code may filter out logs based on its own settings.
If after making these adjustments you still don't see the expected log outputs, double-check the actual function names and ensure they match exactly with what is specified in the host.json
. Additionally, review the runtime version of Azure Functions being used, as logging configurations can slightly differ between runtime versions.