public static void Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { AdminSeedData.Initialize(services); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred seeding the DB."); } } var configuration = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .Build(); var setting = configuration.GetValue <string>("Logging:LogLevel:Default"); Log.Logger = new LoggerConfiguration() .Enrich.WithProperty("Name", "Mick") .Enrich.WithProperty("Environment", configuration.GetValue <string>("Environment")) .Enrich.WithProperty("Component", configuration.GetValue <string>("Component")) .ReadFrom.Configuration(configuration) .MinimumLevel.Is(configuration.GetValue <LogEventLevel>("Logging:LogLevel:Default")) //.MinimumLevel.Override("Microsoft", LogEventLevel.Warning) .Enrich.FromLogContext() .WriteTo.Seq(serverUrl: configuration.GetValue <string>("Logging:Seq:Url"), apiKey: configuration.GetValue <string>("Logging:Seq:ApiKey")) .CreateLogger(); host.Run(); }
//public static IServiceCollection services { get; set; } = new Microsoft.Extensions.DependencyInjection.ServiceCollection(); // public static void Main(String[] args, IConfiguration configuration, Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment)//不支持 public static void Main(String[] args) { //Random random = new Random(); //Int32 portNum = random.Next(5000, 6000); //return WebHost.CreateDefaultBuilder(args).UseStartup<Startup>(); // Int32 seed = 6; //Random random = new Random(seed); Random random = new Random(); Int32 portNum = random.Next(5000, 6000); String urls = "http://*****:*****@"SOFTWARE\jbhuang99")) * { * if (registryKeykey != null) * { * Object obj = registryKeykey.GetValue("Title"); * Console.WriteLine(obj.ToString()); * } * } * } * else { Console.WriteLine("您当前可能不是基于windows操作系统运行本软件!无法自动打开本软件默认的浏览器,将打开本机默认的浏览器作为界面运行本软件,或者,您可以自己手动打开想要的浏览器作为界面运行本软件!"); } * //System.Diagnostics.Process processTemp = new System.Diagnostics.Process(); * //processTemp.StartInfo.FileName = @"C:\Program Files(x86)\Google\Chrome\Application\chrome.exe"; * //processTemp.Start(); **/ }