Beispiel #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment env,
                              BankSeeder seeder,
                              ILoggerFactory logFactory)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();

                logFactory.AddConsole(_config.GetSection("Logging"));
                logFactory.WithFilter(new FilterLoggerSettings()
                {
                    { "Microsoft", LogLevel.Warning },
                    { "System", LogLevel.Warning },
                    { "WorldBank", LogLevel.Information }
                }).AddDebug();

                var config = LogglyConfig.Instance;
                config.CustomerToken              = _config["Loggly:Token"];
                config.ApplicationName            = "WorldBank-BostonCC2016";
                config.Transport.EndpointHostname = "logs-01.loggly.com";
                config.Transport.EndpointPort     = 443;
                config.Transport.LogTransport     = LogTransport.Https;

                var filename = Path.Combine(env.ContentRootPath, "log/serilog.log");
                Log.Logger = new LoggerConfiguration()
                             .Enrich.FromLogContext()
                             .WriteTo.File(filename, Serilog.Events.LogEventLevel.Verbose)
                             .WriteTo.Loggly(Serilog.Events.LogEventLevel.Warning)
                             .CreateLogger();

                logFactory.AddSerilog();
            }
            else
            {
                app.UseExceptionHandler("/Root/Error");
            }

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Root}/{action=Index}/{id?}");
            });

            seeder.SeedDatabaseAsync().Wait();
        }
Beispiel #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment env,
                              BankSeeder seeder,
                              ILoggerFactory loggingFactory)
        {
            var filename = Path.Combine(env.ContentRootPath, "log/log.log");

            Log.Logger = new LoggerConfiguration()
                         .Enrich.FromLogContext()
                         .WriteTo.File(filename, LogEventLevel.Information)
                         .CreateLogger();

            if (env.IsDevelopment())
            {
                loggingFactory.AddSerilog();

                loggingFactory
                .AddConsole(_config.GetSection("Logging"));

                loggingFactory.AddDebug(LogLevel.Information);

                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Root/Error");
            }

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Root}/{action=Index}/{id?}");
            });

            seeder.SeedDatabaseAsync().Wait();
        }
Beispiel #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, BankSeeder seeder, ILoggerFactory loggerFactory)
        {
            if (env.IsDevelopment())
            {
                loggerFactory.AddConsole();

                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Root/Error");
            }

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Root}/{action=Index}/{id?}");
            });

            seeder.SeedDatabaseAsync().Wait();
        }