Skip to content

Allow for the UserLogDefaultLogLevel to be set independent of system logs #4318

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

VineethReyya
Copy link
Contributor

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

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

@VineethReyya VineethReyya requested a review from a team as a code owner March 18, 2025 16:31
@VineethReyya
Copy link
Contributor Author

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

Thanks

{
if (LoggingFilterHelper.ValidUserLogLevels.Contains(UserLogLevel, StringComparer.OrdinalIgnoreCase) == false)
{
throw new CliException($"The userLogLevel value provided, '{UserLogLevel}', is invalid. Valid values are '{string.Join("', '", LoggingFilterHelper.ValidUserLogLevels)}'.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add that the default level for user logs is Information

@liliankasem
Copy link
Member

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

@VineethReyya
Copy link
Contributor Author

VineethReyya commented Mar 20, 2025

@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
Copy link
Contributor Author

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

@liliankasem
Copy link
Member

@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!

Copy link
Contributor

@mattchenderson mattchenderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs way more discussion and design before we try and land a PR here. There need to be lines around config expectations and how that config translates across environments. My personal preference at this moment would be controls as a CLI flags to suppress the system logs, actually.

@VineethReyya
Copy link
Contributor Author

@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
Copy link
Contributor Author

@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

@liliankasem
Copy link
Member

@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.

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

Successfully merging this pull request may close these issues.

Allow for the UserLogDefaultLogLevel to be set independent of system logs
3 participants