private static IHostBuilder CreateHostBuilder(string buildType, string[] args) { return(ProgramBase.CreateHostBuilderDefaults(buildType, args, configBuilder => { configBuilder.SetBasePath(AppContext.BaseDirectory); // 不支持动态更换 如果和json内key的重复了也不会动态更新 configBuilder.AddJsonObject(new { AppSettings = new { //AppId = 0, //AppCode = "", //AppName = "", LogOnConsole = 1, Log4netOpen = 1, } }); configBuilder.AddEnvironmentVariables(); }, configureServicesDelegate: (context, services) => { var configuration = context.Configuration; services.AddHostedService <TestBackgroundService>(); services.Configure <AppSettings>(configuration.GetSection($"{nameof(AppSettings)}")); // LogHelper.RegisterProcessEvent(ConsolePublish); })); }
private static IHostBuilder CreateHostBuilder(string[] args) { return(ProgramBase.CreateHostBuilderDefaults(args, configBuilder => { configBuilder.SetBasePath(AppContext.BaseDirectory) .AddJsonFile("appsettings.json", false, true) ; }, webBuilder => { webBuilder.UseStartup <Startup>(); })); }
private static IHostBuilder CreateHostBuilder(string buildType, string[] args) { return(ProgramBase.CreateHostBuilderDefaults(buildType, args, configBuilder => { configBuilder.SetBasePath(AppContext.BaseDirectory) .AddJsonFile("appsettings.json", false, true) ; }, webHostConfigure: webBuilder => { webBuilder.UseStartup <Startup>(); }, configureServicesDelegate: (context, services) => { var configuration = context.Configuration; // services.AddCtLogService(configuration); RegisterProcessEvent(Log2ConsolePublish); LogHelper.Info("d"); })); }