Skip to content

Question - How/can I use settings with reloadOnChange and LoggingLevelSwitch #72

@dls314

Description

@dls314

I'd like to do something like the following. Is it possible?

appsettings.json

{
  "Serilog": {
    "MinimumLevel": {
      "ControlledBy": {
        "Serilog.Core.LoggingLevelSwitch": "Debug"
      }
    }
  }
}

program.cs

var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
    .AddJsonFile("appsettings.json", reloadOnChange: true)
    //...
    .Build();

Log.Logger = new LoggerConfiguration()
    .ReadFrom.Configuration(configuration)
    //...
    .CreateLogger();

My intent is to modify the config file and have the log level change without restarting the application.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions