N
N
Nikita072021-04-08 14:53:50
Layout
Nikita07, 2021-04-08 14:53:50

What is the correct way to set the inject level of an ILogger?

Hello everyone, the question is the following, there is an ILogger, its configuration is defined in the Program

using (var host = new WebHostBuilder()
              // Код
               .ConfigureLogging(ConfigureLogging)
              // Код

 static void ConfigureLogging(ILoggingBuilder builder)
        {
            builder.AddConsole();
        }


Log entry level defined in appsettings.json file
{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  }
}


and in appsettings.Development.json
{
  "Logging": {
    "LogLevel": {
      "Default": "Warning"
    }
  }
}


Those. in this case, the logger should only keep the warning level and higher, but when it starts up, the info
606eee0195c52521943659.png

level appears And the question itself, where does info come from if it should enter levels from warning ?

p.s. If you change the ConfigureLogging method like this
static void ConfigureLogging(ILoggingBuilder builder)
        {
            builder.AddConsole();
            builder.SetMinimumLevel(LogLevel.Warning);
        }

then logging will only go for warning , but how can you get by with just the appsettings.json file?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor, 2018-05-31
@Blackmilk4

Here the www.pixijs.com library is used to write such an interaction with the username.

V
Vasily Bannikov, 2021-04-08
@vabka

Apparently, your Environment is not Development, so it has not been redefined.
And you also have the logging level explicitly redefined for
Microsoft.Hosting.Lifetime in the base profile, so it will write them from the Information level

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question