Exemplo n.º 1
0
        public void ApplySerilog(IHostBuilder host)
        {
            if (_disableSerilog)
            {
                return;
            }

            host.UseSerilog((context, serilog) =>
                            _serilog.Apply(context, serilog, () =>
            {
                if (Environment.UserInteractive)
                {
                    serilog.WriteTo.Console();
                }

                if (context.HostingEnvironment.IsDevelopment())
                {
                    serilog
                    .MinimumLevel.Information()
                    .MinimumLevel.Override("System", LogEventLevel.Warning)
                    .MinimumLevel.Override("Microsoft", LogEventLevel.Warning);
                }
                else
                {
                    serilog.MinimumLevel.Warning();
                }

                serilog.ReadFrom.Configuration(context.Configuration);
            }));
        }
Exemplo n.º 2
0
        public void ApplyServices <TArea>(IHostBuilder host) where TArea : TimelineArea, new() =>
        host.ConfigureServices((context, services) =>
                               _services.Apply(context, services, () =>
        {
            services.AddTotemRuntime();

            services.AddTimeline <TArea>(timeline =>
                                         _timeline.Apply(context, timeline, () =>
                                                         timeline.AddEventStore().BindOptionsToConfiguration()));

            // Allow an external host (such as a Windows Service) to stop the application
            services.AddSingleton <IHostedService>(p =>
                                                   new ServiceAppCancellation(p.GetService <IApplicationLifetime>(), _cancellationToken));
        }));
Exemplo n.º 3
0
        public void ApplyAppConfiguration(IHostBuilder host) =>
        host.ConfigureAppConfiguration((context, appConfiguration) =>
                                       _appConfiguration.Apply(context, appConfiguration, () =>
        {
            appConfiguration
            .AddEnvironmentVariables()
            .AddCommandLine(Environment.GetCommandLineArgs())
            .AddJsonFile("appsettings.json", optional: true)
            .AddJsonFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.json", optional: true);

            if (context.HostingEnvironment.IsDevelopment())
            {
                appConfiguration.AddUserSecrets(Assembly.GetEntryAssembly(), optional: true);
            }
        }));