5

Is there a property / method in Serilog where I could (programmatically) check the current configuration? (sinks, minimum level)

e.g. if have this config:

Log.Logger = new LoggerConfiguration()
    .MinimumLevel.Debug()
    .WriteTo.File("log.txt")
    .WriteTo.Console(restrictedToMinimumLevel: LogEventLevel.Information)
    .CreateLogger();

How could I read this config later?

(In my case the config is dynamically created outside my application)

Julian
  • 30,223
  • 19
  • 105
  • 147

1 Answers1

3

No, there's no reflective way to examine Serilog configuration.

Nicholas Blumhardt
  • 28,098
  • 4
  • 83
  • 98
  • 2
    That's unexpected! So if you like to alter the config, you need to recreate the whole config, isn't? – Julian Jul 08 '19 at 08:39
  • PS in NLog reading and changing the config could be done by `LogManager.Configuration`. So I was looking for that ;) – Julian Jul 08 '19 at 08:40
  • Yep, we do things differently :-) – Nicholas Blumhardt Jul 09 '19 at 05:17
  • 1
    That is really inconvenient! I have reqs to store settings in db after first load to prevent user messing with config file. I guess will have to store the whole json... Why it would be a problem to expose these configs read-only? In this case "differently"=drawback. – lentyai Nov 28 '19 at 03:36