azure-functions-core-tools icon indicating copy to clipboard operation
azure-functions-core-tools copied to clipboard

Allow for the UserLogDefaultLogLevel to be set independent of system logs

Open VineethReyya opened this issue 9 months ago • 8 comments

Issue describing the changes in this PR

Added --flag userLogLevel to set UserLogDefaultLogLevel without having to set the default log level, and without having to also set the SystemLogDefaultLogLevel to the same value.

resolves #4295

Pull request checklist

  • [x] My changes do not require documentation changes
    • [ ] Otherwise: Documentation issue linked to PR
  • [x] My changes do not need to be backported to a previous version
    • [ ] Otherwise: Backport tracked by issue/PR #issue_or_pr
  • [x] I have added all required tests (Unit tests, E2E tests)

VineethReyya avatar Mar 18 '25 16:03 VineethReyya

@liliankasem could you review the changes when have a moment.

Thanks

VineethReyya avatar Mar 18 '25 16:03 VineethReyya

Thanks, did you also investigate option (b) in my proposal? It would be good to see if that works?

Second, can you validate this works for all language workers?

I am still on the fence between a flag or env var for this

liliankasem avatar Mar 18 '25 18:03 liliankasem

@liliankasem

If we set "AzureFunctionsJobHost__Logging__LogLevel__Function" to 'debug' in local.settings.json or also use as an environment variable: Its showing debug logs for dotnet worker (if we set minimum level in program.cs), dotnet, Node, Python without depending on host.json. For Python changes PFB screenshot: using "AzureFunctionsJobHost__Logging__LogLevel__Function": "Debug" in local.settings.json file

(image)

The changes were made to setup the value of UserLoglevel and systemLogLevel be different by using --userLoglevel flag to show logs based on loglevel is not working. it's still depending on host.json

can i set the value of 'AzureFunctionsJobHost__Logging__LogLevel__Function' as UserLogDefaultLogLevel instead of --userLogLevel flag?

VineethReyya avatar Mar 20 '25 11:03 VineethReyya

@liliankasem added new changes and tests. could you provide review. Thanks

VineethReyya avatar Mar 25 '25 16:03 VineethReyya

@liliankasem added new changes and tests. could you provide review. Thanks

Sorry I didn't mean for you to remove the implementation for the --userLogLevel flag, just that we should decide which approach.

@aishwaryabh @mattchenderson @soninaren - can you share thoughts on what you think here?

a) We can provide a flag for users to set on func start => --userLogLevel

b) We can provide an environment variable that can be set in local.settings.json or in local env => ``

c) We can use the existing host.json logging properties. We know that a Function log category exists already, we can utilize that here. This might be a little more complicated in code as we would want to do something like:

  • if default is set, and Function is not set == set default value for both user and system
  • if defailt is not set, and Function is set == set user log value to Function
  • if default is set, and Functionis set == usedefaultfor system andFunction` for user logs
    "logLevel": {
      "default": "Warning",
      "Host.Aggregator": "Trace",
      "Host.Results": "Information",
      "Function": "Information" // use this to set user log level
    }

I am thinking we do both a and c - where users can utilize the host config file or they can set the flag with a func start command as a one off debug situation. Thoughts?

@VineethReyya lets hold off on more changes until we have consensus with the team, thanks!

liliankasem avatar Mar 25 '25 20:03 liliankasem

@liliankasem added new changes and tests. could you provide review. Thanks

Sorry I didn't mean for you to remove the implementation for the --userLogLevel flag, just that we should decide which approach.

@aishwaryabh @mattchenderson @soninaren - can you share thoughts on what you think here?

a) We can provide a flag for users to set on func start => --userLogLevel

b) We can provide an environment variable that can be set in local.settings.json or in local env => ``

c) We can use the existing host.json logging properties. We know that a Function log category exists already, we can utilize that here. This might be a little more complicated in code as we would want to do something like:

  • if default is set, and Function is not set == set default value for both user and system
  • if defailt is not set, and Function is set == set user log value to Function
  • if default is set, and Functionis set == usedefaultfor system andFunction` for user logs
    "logLevel": {
      "default": "Warning",
      "Host.Aggregator": "Trace",
      "Host.Results": "Information",
      "Function": "Information" // use this to set user log level
    }

I am thinking we do both a and c - where users can utilize the host config file or they can set the flag with a func start command as a one off debug situation. Thoughts?

@VineethReyya lets hold off on more changes until we have consensus with the team, thanks!

@liliankasem Based on your inputs, I made changes work for both 'a' and 'c'. please review when you have a moment Thanks for the help.

VineethReyya avatar Apr 04 '25 13:04 VineethReyya

@liliankasem @aishwaryabh Following up on my previous message—could you please take a moment to review the changes? I’d appreciate your feedback when convenient

VineethReyya avatar Apr 16 '25 13:04 VineethReyya

@liliankasem @aishwaryabh Following up on my previous message—could you please take a moment to review the changes? I’d appreciate your feedback when convenient

Lets put this on pause for now whilst we dicuss internally how we want to do this.

liliankasem avatar Apr 16 '25 17:04 liliankasem