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

Logger not adding anything below debug warning level #48

Closed
andrejaj opened this issue Jan 26, 2023 · 1 comment
Closed

Logger not adding anything below debug warning level #48

andrejaj opened this issue Jan 26, 2023 · 1 comment
Labels

Comments

@andrejaj
Copy link

So ive done same as others

"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Debug",
"Microsoft.Hosting.Lifetime": "Debug"
},
"File": {
"MinLevel": "Debug",
"Path": "app.log",
"Append": "True",
"FileSizeLimitBytes": 10485760, // 10 * 1024 * 1024 => 10MB
"MaxRollingFiles": 3 // use to specify max number of log files
}
}

and it seems anything belowWarning is not added to log file.
Can you help on this as im about to use another logger.

_logger.Debug - not added to log file

_logger.Warning - added to log file

also ive used to load settings with code below.

services.AddLogging(loggingBuilder =>
{
var loggingSection = hostContext.Configuration.GetSection("Logging");
loggingBuilder.AddFile(loggingSection);
});

@VitaliyMF
Copy link
Contributor

I see that your default logging level is "Information" (which is configured on the logging infrastructure side), so it is normal that "Debug" messages are not logged, because they are filtered on Microsoft.Extensions.Logging side and FileLoggerProvider simply didn't get them at all.

With "File":"MinLevel" you can specify additional filtering of messages that are pushed to the logging provider, but undesired exactly for your log file. For example, if you specify "MinLevel":"Warning" and keep "Default":"Information" you may exclude "Information" messages from the log file, but other logging providers will show them (say, console).

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

No branches or pull requests

2 participants