I know there is new update in serilog where you can do conditional logging as shown in below code however that is part of preconfiguration, but I need to write to either to File1 or File2 at run time, well File1 will be used to push data to EventViewer and File2 will be used to push data to SQL database using fluentd.
bool enableFileLogging1 = ...
bool enableFileLogging2 = ...
var builder = new LoggerConfiguration()
.Enrich.WithExceptionDetails()
.Enrich.FromLogContext()
.MinimumLevel.Warning()
.WriteTo.Conditional(evt => enableFileLogging1, wt => wt.File())
.WriteTo.Conditional(evt => enableFileLogging2, wt => wt.File(...));
Log.Logger = builder.CreateLogger();