public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .ConfigureServices((context, services) => { //获取核心配置 var coreConfiguration = ConfigurationContainer.Get <CoreConfiguration>(ConfigurationNames.Application); //初始化DI容器 MainStartupHelper.InitDI(services, coreConfiguration.DISetting); //初始化静态设置 MainStartupHelper.InitStaticInfo(); }) .ConfigureLogging((builder) => { //初始化日志配置 MainStartupHelper.InitLogger(builder); }) .ConfigureAppConfiguration((context, builder) => { //context.HostingEnvironment.EnvironmentName }) .UseConfiguration(ConfigurationContainer.GetConfiguration(ConfigurationNames.Host)) .UseStartup <Startup>();
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseIISIntegration() .ConfigureServices((context, services) => { //初始化配置容器 StartupHelper.InitConfigurationContainer(context.HostingEnvironment.EnvironmentName, _baseUrl); //获取核心配置 var coreConfiguration = ConfigurationContainer.Get <CoreConfiguration>(ConfigurationNames.Application); //初始化DI容器 MainStartupHelper.InitDI(services, coreConfiguration.DISetting); //初始化静态设置 MainStartupHelper.InitStaticInfo(); StartupHelper.InitStaticInfo(); //配置日志工厂 var loggerFactory = LoggerFactory.Create((builder) => { MainStartupHelper.InitLogger(builder); }); DIContainerContainer.Inject <ILoggerFactory>(loggerFactory); }) .ConfigureLogging((builder) => { //初始化日志配置 //MainStartupHelper.InitLogger(builder); }) .ConfigureKestrel(opts => { }) .UseConfiguration(ConfigurationContainer.GetConfiguration(ConfigurationNames.Host)) .UseStartup <Startup>();