Exemple #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, Log4netDBContext context, ILoggerFactory loggerFactory)
        {
            string connectionString = Configuration["Logging:ConnectionString"];
            string logFilePath      = Configuration["Logging:LogFilePath"];

            loggerFactory.AddLog4Net(new[]
            {
                log4netConfiguration.CreateConsoleAppender(),
                log4netConfiguration.CreateRollingFileAppender(logFilePath),
                log4netConfiguration.CreateTraceAppender(),
                log4netConfiguration.CreateAdoNetAppender(connectionString)
            });

            DBInitializer.Initialize(context);

            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
 public static void Initialize(Log4netDBContext context)
 {
     context.Database.EnsureCreated();
 }