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

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

Closed
dls314 opened this issue Nov 1, 2017 · 2 comments
Closed

Comments

@dls314
Copy link

dls314 commented Nov 1, 2017

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.

@nblumhardt
Copy link
Member

Hi Dave, this should just work straight out of the box with the normal "MinimumLevel": "Debug" syntax:

https://github.com/serilog/serilog-settings-configuration/blob/dev/src/Serilog.Settings.Configuration/Settings/Configuration/ConfigurationReader.cs#L69

Not having any luck with it?

@dls314
Copy link
Author

dls314 commented Nov 1, 2017

I thought it was a far fetched ask and haven't worked up a test. Thanks for answering :-)

@dls314 dls314 closed this as completed Nov 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants