// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory factory, IServiceProvider provider) { factory.AddDbLogging <ApplicationDbContext>(provider, LogLevel.Information); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseHttpsRedirection(); } else { app.UseHsts(); app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto }); } app.UseSignalR(route => { route.MapHub <ChatHub>("/hubs/chat"); }); app.UseAuthentication(); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IOptions <DatabaseSettings> settings) { if (env.IsDevelopment()) { loggerFactory.AddConsole(); app.UseDeveloperExceptionPage(); } loggerFactory.AddDbLogging(settings); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v0.0.1/swagger.json", "Camps API"); }); app.UseMvc(); }
public static void AddDbLogging <T>(this ILoggerFactory factory, IServiceProvider provider, LogLevel minimum) where T : DbContext { factory.AddDbLogging <T>(provider, (name, level) => { return(name != "Microsoft.EntityFrameworkCore.Infrastructure" && name != "Microsoft.EntityFrameworkCore.Database.Command" && level >= minimum); }); }