Ejemplo n.º 1
0
        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, Microsoft.Framework.Logging.ILoggerFactory loggerfactory)
        {
            // Configure the HTTP request pipeline.
            // Add the console logger.
            loggerfactory.AddConsole();

            // Add the following to the request pipeline only in development environment.
            if (string.Equals(env.EnvironmentName, "Development", StringComparison.OrdinalIgnoreCase))
            {
                app.UseErrorPage(ErrorPageOptions.ShowAll);
            }
            else
            {
                // Add Error handling middleware which catches all application specific errors and
                // send the request to the following path or controller action.
                app.UseErrorHandler("/Home/Error");
            }

            // Add static files to the request pipeline.
            app.UseStaticFiles();

            // Add MVC to the request pipeline.
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" });

                // Uncomment the following line to add a route for porting Web API 2 controllers.
                // routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}");
            });
        }
Ejemplo n.º 2
0
        internal OwinLoggerFactory(Microsoft.Framework.Logging.ILoggerFactory loggerFactory)
        {
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            _loggerFactory = loggerFactory;
        }
Ejemplo n.º 3
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory, IApplicationLifetime lifetime, IBusManager busManager)
        {
            loggerfactory.AddSerilog();

            Log.Information("Configuring the Application");

            app.UseCors(_aureliaAppPolicyName);

            var options = new IdentityServerBearerTokenAuthenticationOptions
            {
                Authority      = _appSettings.IdentityServerAuthority,
                RequiredScopes = new[] { _appSettings.IdentityServerSettings.ClientId },
                NameClaimType  = "preferred_username"
            };

            app.UseAppBuilder(
                builder =>
            {
                builder.SetLoggerFactory(LoggerFactory.Default);
                builder.UseIdentityServerBearerTokenAuthentication(options);
            },
                _appSettings.ServiceSettings.ServiceName);

            app.UseMiddleware <ContextMiddleware>();
            app.UseMvc();

            Log.Information("Getting ready to start the bus manager");

            busManager.Start(
                new[] { typeof(StartApplication).Assembly, Assembly.GetExecutingAssembly() },
                config => config.RegisterComponents(r => r.ConfigureComponent <OutgoingAppContextMutator>(DependencyLifecycle.InstancePerUnitOfWork)));

            lifetime.ApplicationStopping.Register(busManager.Stop);

            _loggingLevelSwitch.MinimumLevel = LogEventLevel.Information;
        }
Ejemplo n.º 4
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory, IApplicationLifetime lifetime, IBusManager busManager)
        {
            loggerfactory.AddSerilog();

            Log.Information("Configuring the Application");

            app.UseCors(_aureliaAppPolicyName);

            var options = new IdentityServerBearerTokenAuthenticationOptions
            {
                Authority = _appSettings.IdentityServerAuthority,
                RequiredScopes = new[] { _appSettings.IdentityServerSettings.ClientId },
                NameClaimType = "preferred_username"
            };

            app.UseAppBuilder(
                builder =>
                {
                    builder.SetLoggerFactory(LoggerFactory.Default);
                    builder.UseIdentityServerBearerTokenAuthentication(options);
                },
                _appSettings.ServiceSettings.ServiceName);

            app.UseMiddleware<ContextMiddleware>();
            app.UseMvc();

            Log.Information("Getting ready to start the bus manager");

            busManager.Start(
                new[] { typeof(StartApplication).Assembly, Assembly.GetExecutingAssembly() },
                config => config.RegisterComponents(r => r.ConfigureComponent<OutgoingAppContextMutator>(DependencyLifecycle.InstancePerUnitOfWork)));

            lifetime.ApplicationStopping.Register(busManager.Stop);

            _loggingLevelSwitch.MinimumLevel = LogEventLevel.Information;
        }
Ejemplo n.º 5
0
        public Startup(IApplicationEnvironment appEnv, IHostingEnvironment hostingEnv, Microsoft.Framework.Logging.ILoggerFactory loggerFactory)
        {
            var serilogLogger = new LoggerConfiguration()
                                .WriteTo.TextWriter(Console.Out)
                                .MinimumLevel.Verbose()
                                .CreateLogger();

            var config = new ConfigurationBuilder()
                         .SetBasePath(appEnv.ApplicationBasePath)
                         .AddJsonFile("config.json")
                         .AddEnvironmentVariables("ModernShoppingAuthSampleApp_")
                         .Build();

            Log.Logger = serilogLogger;
            loggerFactory.MinimumLevel = LogLevel.Debug;
            loggerFactory.AddSerilog(serilogLogger);

            _appEnv        = appEnv;
            _hostingEnv    = hostingEnv;
            _logger        = new Logger <Startup>(loggerFactory);
            _configuration = config;
        }