I created a functionapp using a container image - How can I send the request logs, container and system logs to application insights?

Zen 0 Reputation points
2023-10-13T04:48:23.74+00:00

I have created a python application function app using a container image, how ever I can't see any stats and some of my logs to the connected application insights.

User's image

I have this python code to target my application insights

logger = logging.getLogger(__name__)
logger.addHandler(AzureLogHandler(connection_string=os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")))
logger.info(f'------ Loading function {__name__} ------')

I have this setting in my host.json file

{
  "version": "2.0",
  "logging": {
    "fileLoggingMode": "debugOnly",
    "logLevel": {
      "default": "Information",
      "Host.Results": "Error",
      "Function": "Error",
      "Host.Aggregator": "Trace"
    },
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[3.*, 4.0.0)"
  },
  "extensions": 
  {
    "http": 
    {
        "routePrefix": ""
    }
  }
}

From the logs blade, and query "traces", I can see the error log but not the info logs.User's image

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.