private static Logger CreateLogger(GeneralCommandInfos commandInfos) { var logFileName = commandInfos switch { CleanCommand _ => "clean.log", RestoreCommand _ => "restore.log", DropDatabaseCommand _ => "drop.log", _ => throw new NotImplementedException("Type not supported") }; var level = commandInfos.Verbose ? LogEventLevel.Debug : LogEventLevel.Information; var loggerConf = new LoggerConfiguration() .WriteTo.Async(conf => { var path = commandInfos.LogsPath?.Exists == true ? Path.Combine(commandInfos.LogsPath.FullName, logFileName) : "logs/" + logFileName; conf.File(path, rollingInterval: RollingInterval.Day, retainedFileCountLimit: 31); conf.Console(); }).MinimumLevel.Is(level); return(loggerConf.CreateLogger()); } }