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

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

Open
liliankasem opened this issue Mar 12, 2025 · 2 comments · May be fixed by #4318
Open

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

liliankasem opened this issue Mar 12, 2025 · 2 comments · May be fixed by #4318

Comments

@liliankasem
Copy link
Member

Description

In Core Tools today, the log level for user logs can only be set as the same value of system logs via the "default" property in host.json:

if (Utilities.LogLevelExists(hostJsonConfig, Utilities.LogLevelDefaultSection, out LogLevel logLevel))
{
SystemLogDefaultLogLevel = logLevel;
UserLogDefaultLogLevel = logLevel;
}

internal static bool DefaultLoggingFilter(string category, LogLevel actualLevel, LogLevel userLogMinLevel, LogLevel systemLogMinLevel)

And this is the only way to control the logs that user's can see when they run their application.

This is frustrating as you won't be able to see your debug logs without also seeing all of the debug logs coming from the system, and there is no way to filter those out.

Proposal

We can fix this either by

a) exposing a way for customers to set UserLogDefaultLogLevel without having to set the default log level, and/or without having to also set the SystemLogDefaultLogLevel to the same value. This could be through something like a flag i.e. --userLogLevel Debug, or environment setting. I would advise against this being a host.json setting.

b) implement a way for us to respect the settings coming from workers. For example, in dotnet-isolated, you can set the min log level in your Program.cs:

builder.Logging.SetMinimumLevel(LogLevel.Debug);

Is there a way we can respect this setting without having to make customers manually configure UserLogDefaultLogLevel as well?

I did also find that instead of setting the log level in Program.cs - you can also use appsettings.json; Core Tools(?) is respecting any appsettings.json file that is provided without any additional config, however logLevel in host.json is still required.

This might be future work rather than immediate fix, but with the Core Tools refactor we are thinking about tools for each stack, and part of that could include logging management per stack.

Considerations

  1. We often tell customers, and document, that host.json is only used to control host logs, and not worker logs. So it is confusing that you have to set the host log level to control your worker logs. I think we need a mechanism outside of host.json to control this.

  2. My understanding is that this is an issue that only impacts local development so there shouldn't be need for changes in the workers

  3. How do other workers outside of dni allow customers to configure their logging setttings? Does that need to be taken into account?

@VineethReyya
Copy link
Contributor

VineethReyya commented Mar 17, 2025

@liliankasem I was able to reproduce it my local development.
By default, Function App log_level is set to information, so, it's filtering out all the debug level logs. could you provide more context on this to proceed further on this?

As you said, we are controlling logs In line 237

But if I debug, the logs of level lower than information is filtering out before coming into this line of code.

-> if we make changes manually in program.cs by setting minlevel to debug then its working

@liliankasem
Copy link
Member Author

The default is correct and should stay that way, please refer to the PR description for suggestions I have made to address this issue.

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