Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Handler Logging #2575

Open
nad-au opened this issue Jan 7, 2025 · 1 comment
Open

Custom Handler Logging #2575

nad-au opened this issue Jan 7, 2025 · 1 comment

Comments

@nad-au
Copy link

nad-au commented Jan 7, 2025

According to https://learn.microsoft.com/en-us/azure/azure-functions/functions-custom-handlers#response-payload when the handler response contains a Logs array, these are shown in the invocation logs.

For example:

{
  "Outputs": {
    "res": {
      "Headers": {"Content-Type": "application/json"},
      "statusCode": 200,
      "body": {"message": "Order received for P01 qty 1"}
    }
  },
  "Logs": ["Order received for P01", "Order quantity 1"]
}

The invocation logs never include these log entries. In fact the Invocations form does not even show successful invocations and searching through trace logs, these Logs entries are never found.

In addition, searching through trace logs, there's also no invocation id and its also impossible to determine which function endpoint is responsible for generating the trace logs.

Is there any more documentation for custom handler logging so that logs produced are of similar quality and use when using the supported sdks eg node or C#? I have some working handlers using https://bun.sh/ but they are useless without logging.

Ideally I'd like to achieve:

  • Shows successful invocations per function endpoint
  • Search trace logs per invocation and/or per endpoint
  • Reduce the logs noise. Filter traces on custom (console logs) and filter out function host logs
@nad-au
Copy link
Author

nad-au commented Jan 7, 2025

Logs are now working. Looking further into the documentation https://learn.microsoft.com/en-us/azure/azure-functions/configure-monitoring?tabs=v2#configure-categories there's two categories in particular which must be set:

  • Function: set to Information in order to emit the Logs
  • Host.Results set to Information to indicate a success / failure

My host.json log setting:

    "logging": {
        "logLevel": {
            "default": "Warning",
            "Host.Aggregator": "Warning",
            "Host.Results": "Information",
            "Function": "Information",
            "Worker": "Warning"
        }
    },

Now shows operation-level logs along with the operation id

Image

and Invocations form and corresponding logs is now working

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant