Closed andrejaj closed 1 year ago
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).
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); });