// 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) { //add NLog to ASP.NET Core loggerFactory.AddNLog(); //needed for non-NETSTANDARD platforms: configure nlog.config in your project root env.ConfigureNLog("nlog.config"); loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseApplicationInsightsRequestTelemetry(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseApplicationInsightsExceptionTelemetry(); app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
// 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) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseIISPlatformHandler(); app.UseStaticFiles(); app.UseMvc(); // Create a catch-all response app.Run(async (context) => { var logger = loggerFactory.CreateLogger("Catchall Endpoint"); logger.LogInformation("No endpoint found for request {path}", context.Request.Path); await context.Response.WriteAsync("No endpoint found."); }); //add NLog to aspnet5 loggerFactory.AddNLog(); //configure nlog.config in your project root env.ConfigureNLog("nlog.config"); }
// 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) { loggerFactory.AddNLog(); env.ConfigureNLog("nlog.config"); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseExecuteTime(); app.UseMvc(); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { var filter = new BasicAuthAuthorizationFilter( new BasicAuthAuthorizationFilterOptions { SslRedirect = false, // 是否将所有非SSL请求重定向到SSL URL RequireSsl = false, // 需要SSL连接才能访问HangFire Dahsboard。强烈建议在使用基本身份验证时使用SSL LoginCaseSensitive = false, //登录检查是否区分大小写 Users = new[] { new BasicAuthAuthorizationUser { Login = Configuration["Hangfire:Login"], PasswordClear = Configuration["Hangfire:PasswordClear"] } } }); app.UseHangfireDashboard("", new DashboardOptions { Authorization = new[] { filter }, }); //配置要处理的队列列表 ,如果多个服务器同时连接到数据库,会认为是分布式的一份子。可以通过这个配置根据服务器性能的按比例分配请求,不会导致服务器的压力。不配置则平分请求 var jobOptions = new BackgroundJobServerOptions { Queues = new[] { "critical", "test", "default" }, //队列名称,只能为小写 排在前面的优先执行 WorkerCount = Environment.ProcessorCount * int.Parse(Configuration["Hangfire:ProcessorCount"]), //并发任务数 --超出并发数。将等待之前任务的完成 (推荐并发线程是cpu 的 5倍) ServerName = Configuration["Hangfire:ServerName"], //服务器名称 }; app.UseHangfireServer(jobOptions); //启动hangfire服务 Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); //这是为了防止中文乱码 loggerFactory.AddNLog(); //添加NLog env.ConfigureNLog("nlog.config"); //读取Nlog配置文件 app.UseMvc(); }
private void ConfigureLog(IApplicationBuilder app, ILoggerFactory loggerFactory, IHostingEnvironment env) { // add NLog to .NET Core loggerFactory.AddNLog(); //Enable ASP.NET Core features (NLog.web) - only needed for ASP.NET Core users app.AddNLogWeb(); //needed for non-NETSTANDARD platforms: configure nlog.config in your project root. NB: you need NLog.Web.AspNetCore package for this. env.ConfigureNLog("nlog.config"); LogManager.Configuration.Variables["connectionString"] = Configuration.GetConnectionString("eCafeConnection"); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } //else //{ // // handling exception across application level // app.UseExceptionHandler(appBuilder => // { // appBuilder.Run(async context => // { // var exceptionHandler = context.Features.Get<IExceptionHandlerFeature>(); // if (exceptionHandler != null) // { // var logger = loggerFactory.CreateLogger("Global exception Logger"); // logger.LogError(500, exceptionHandler.Error, exceptionHandler.Error.Message); // } // context.Response.StatusCode = 500; // await context.Response.WriteAsync("An unexpected error occurred. please try again later."); // }); // }); // app.UseExceptionHandler("/Home/Error"); //} }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApplicationLifetime applicationLifetime) { var log = loggerFactory .AddNLog() //.AddConsole() //.AddDebug() .CreateLogger <Startup>(); env.ConfigureNLog("NLog.config"); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); // add tenant & health check var localAddress = DnsHelper.GetIpAddressAsync().Result; var uri = new Uri($"http://{localAddress}:{Program.PORT}/"); log.LogInformation("Registering tenant at ${uri}"); var registryInformation = app.AddTenant("values", "1.7.0-pre", uri, tags: new[] { "urlprefix-/values" }); log.LogInformation("Registering additional health check"); var checkId = app.AddHealthCheck(registryInformation, new Uri(uri, "randomvalue"), TimeSpan.FromSeconds(15), "random value"); // prepare checkId for options injection app.ApplicationServices.GetService <IOptions <HealthCheckOptions> >().Value.HealthCheckId = checkId; // register service & health check cleanup applicationLifetime.ApplicationStopping.Register(() => { log.LogInformation("Removing tenant & additional health check"); app.RemoveHealthCheck(checkId); app.RemoveTenant(registryInformation.Id); }); }
// 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) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseCors(builder => { builder.AllowAnyHeader(); builder.AllowAnyMethod(); builder.AllowCredentials(); builder.AllowAnyOrigin(); }); env.ConfigureNLog("nlog.config"); loggerFactory.AddNLog(); app.AddNLogWeb(); } else if (env.IsProduction()) { //TODO: Configure that properly app.UseCors( optCors => optCors.WithOrigins("http://localhost:4200/").AllowAnyMethod()); loggerFactory.AddAzureWebAppDiagnostics(); // loggerFactory.AddApplicationInsights(app.ApplicationServices); } app.UseAuthentication(); app.UseMiddleware(typeof(ErrorHandlerMiddleware)); app.UseMvc(); app.UseStaticFiles(); //Multi-languages var optLanguages = app.ApplicationServices.GetService <IOptions <RequestLocalizationOptions> >(); app.UseRequestLocalization(optLanguages.Value); }
// 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) { Console.WriteLine(FiggleFonts.Standard.Render("Find-A-Tutor API")); loggerFactory.AddNLog(); env.ConfigureNLog("nlog.config"); app.UseSwagger() .UseSwagger() .UseSwaggerUI(options => { options.SwaggerEndpoint( $"{ (!string.IsNullOrEmpty(PathBase) ? PathBase : string.Empty)}/swagger/v1/swagger.json", "Find-A-Tutor Api"); }); //HealthChecks app.UseHealthChecks("/health", new HealthCheckOptions() { Predicate = _ => true, ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse }); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseErrorHandler(); app.UseAuthentication(); //app.UseHttpsRedirection(); 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) { string appRoot = env.ContentRootPath; AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(appRoot, "App_Data")); var dbConnection = $@"Data Source={AppDomain.CurrentDomain.GetData("DataDirectory")}\LightBlogData.db;"; AppDomain.CurrentDomain.SetData(Constants.DbConnectionName, dbConnection); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } env.ConfigureNLog("nlog.config"); app.UseStaticFiles(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Post}/{action=Index}/{id?}"); }); // make sure Chinese chars don't f**k up Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); //add NLog to ASP.NET Core loggerFactory.AddNLog(); //add NLog.Web app.AddNLogWeb(); }
// 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) { env.ConfigureNLog("nlog.config"); loggerFactory.AddNLog(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvc(); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Core2io Service API V1"); }); app.UseMetricServer(); }
// 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) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); loggerFactory.AddNLog(); env.ConfigureNLog("nlog.config"); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
// 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) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { } //设置log打印 loggerFactory.AddNLog(); //设置nlog配置 env.ConfigureNLog("Config/config_nlog.config"); //启用验证 app.UseAuthentication(); //启用跨越 app.UseCors("Any"); app.UseMvc(); }
public Startup(IHostingEnvironment env, ILoggerFactory loggerFactory, ILogger <Startup> logger) { this.loggerFactory = loggerFactory; this.logger = logger; var path = ApplicationLogger.GetConfigPath(env.EnvironmentName); loggerFactory.AddDebug(); loggerFactory.AddNLog(); logger.LogInformation($"Starting RawCMS, environment={env.EnvironmentName}"); env.ConfigureNLog(path); ApplicationLogger.SetLogFactory(loggerFactory); IConfigurationBuilder builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .AddEnvironmentVariables(); Configuration = builder.Build(); }
// 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) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } loggerFactory.AddNLog(); app.AddNLogWeb(); if (!TestStatus.IsRunningIntegrationTests) { env.ConfigureNLog("NLog.config"); } loggerFactory.AddNLog(); app.UseMvc(); app.UseSwagger(); app.UseSwaggerUI(cw => { cw.SwaggerEndpoint("/swagger/v1/swagger.json", "LBH Abestos API v1"); }); }
/// <summary> /// Constructor of initializer /// </summary> /// <param name="env"></param> public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .AddJsonFileEncrypted($"appsettings.{env.EnvironmentName}.crypt", AppSettingsKey, optional: true) .AddEnvironmentVariables(); Configuration = builder.Build(); PtvConfiguration = new ApplicationConfiguration(Configuration); // NLog renderers LayoutRenderer.Register("json-message", logEvent => $"\"{logEvent.Message}\""); LayoutRenderer.Register("job-type", logEvent => logEvent.Properties.ContainsKey("JobType") ? logEvent.Properties["JobType"] : null); LayoutRenderer.Register("job-status", logEvent => logEvent.Properties.ContainsKey("JobStatus") ? logEvent.Properties["JobStatus"] : null); LayoutRenderer.Register("execution-type", logEvent => logEvent.Properties.ContainsKey("ExecutionType") ? logEvent.Properties["ExecutionType"] : null); var environmentLogConfigurationName = $"nlog.{env.EnvironmentName}.config"; env.ConfigureNLog(File.Exists(environmentLogConfigurationName) ? environmentLogConfigurationName : "nlog.config"); //if (env.IsDevelopment()) TaskSchedulerLogger.ClearAllLogs(); }
public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .AddEnvironmentVariables(); if (env.IsDevelopment()) { // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709 builder.AddUserSecrets <Startup>(); } Configuration = builder.Build(); // set nlog config env.ConfigureNLog("nlog.config"); LogManager.Configuration.Variables["connectionString"] = Configuration.GetConnectionString("DefaultConnection"); LogManager.Configuration.Install(new InstallationContext()); Environment = env; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime appLifetime, ILoggerFactory loggerFactory) { env.ConfigureNLog("nlog.config"); //add NLog to ASP.NET Core loggerFactory.AddNLog(); //add NLog.Web app.AddNLogWeb(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvc(); appLifetime.ApplicationStarted.Register(OnStarted); appLifetime.ApplicationStopping.Register(OnStopping); appLifetime.ApplicationStopped.Register(OnStopped); _logger = loggerFactory.CreateLogger("StartupLogger"); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } env.ConfigureNLog("nlog.config"); app.UseHttpsRedirection(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Customers API"); c.RoutePrefix = string.Empty; }); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IHostingEnvironment env, IApplicationLifetime appLifetime) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCors(builder => { builder.AllowAnyOrigin(); }); loggerFactory.AddNLog(); app.AddNLogWeb(); env.ConfigureNLog("nlog.config"); app.UseUserAuthentication();//要放在UseMvc前面 app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseMvc(); appLifetime.ApplicationStopped.Register(() => this.Container.Dispose()); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); //NLog loggerFactory.AddNLog(); var dir = new DirectoryInfo("NLog"); var path = Path.Combine(dir.FullName, "", $"NLog.{env.EnvironmentName}.config"); env.ConfigureNLog(path); }
/// <summary> /// 配置请求管道(中间件) /// </summary> /// <param name="app"></param> /// <param name="env"></param> /// <param name="loggerFactory">日志工厂</param> public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { // if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } //NLog loggerFactory.AddNLog(); env.ConfigureNLog("nlog.config"); //Swagger app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "这是显示在右上角的文字"); }); //调用中间件 //app.UseMiddleware<JwtToken>(); //设置可访问静态文件 app.UseStaticFiles(); //默认MVC 路径 app.UseMvcWithDefaultRoute(); }
// 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) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseExceptionHandler(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); }); env.ConfigureNLog("nlog.config"); loggerFactory.AddNLog(); app.AddNLogWeb(); 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, FeatureToggles features, ILoggerFactory loggerFactory ) { if (features.EnableDeveloperExceptions) { //app.UseDeveloperExceptionPage(); } app.UseIdentity(); app.UseMvc(routes => { routes.MapRoute("Default", "{controller=Home}/{action=Index}/{id?}" ); }); app.UseFileServer(); var location = System.Reflection.Assembly.GetEntryAssembly().Location; location = location.Substring(0, location.LastIndexOf(Path.DirectorySeparatorChar)); location = location + Path.DirectorySeparatorChar + "NLog.config"; env.ConfigureNLog(location); loggerFactory.AddNLog(); app.AddNLogWeb(); app.UseExceptionHandler("/Home/Error"); app.UseStatusCodePagesWithRedirects("/StatusCode/{0}"); app.UseStaticFiles(); }
// 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) { app.UseSession(); //使用NLog作为日志记录工具 loggerFactory.AddNLog(); env.ConfigureNLog(AppContext.BaseDirectory + "config/nlog.config");//读取Nlog配置文件 if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseCookiePolicy(); //验证中间件 app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "CMS", template: "{area:exists}/{controller=Home}/{action=Index}/{id?}" ); routes.MapRoute( name: "SYS", template: "{area:exists}/{controller=Home}/{action=Index}/{id?}" ); routes.MapRoute( name: "default", template: "{controller=Home}/{action=Login}/{id?}"); }); Init(app); }
// 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) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); loggerFactory.AddFile("Logs/ts-{Date}.txt"); //add NLog to .NET Core loggerFactory.AddNLog(); //Enable ASP.NET Core features (NLog.web) - only needed for ASP.NET Core users app.AddNLogWeb(); //needed for non-NETSTANDARD platforms: configure nlog.config in your project root. NB: you need NLog.Web.AspNetCore package for this. env.ConfigureNLog("nlog.config"); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseIdentity(); // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715 app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
// 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) { // loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); loggerFactory.AddNLog(); env.ConfigureNLog($"./conf/NLog.{env.EnvironmentName}.config"); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } appEngine.Plugins.OrderBy(x => x.Priority).ToList().ForEach(x => { x.Configure(app, appEngine); }); app.UseMvc(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{collection?}/{id?}"); }); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); }); app.UseStaticFiles(); app.UseWelcomePage(); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { app.InitializeDatabase(); var serviceConfig = ServiceConfiguration.Configs; //添加NLog到.net core框架中 loggerFactory.AddNLog(); //添加NLog的中间件 app.AddNLogWeb(); //指定NLog的配置文件 env.ConfigureNLog("nlog.config"); //app.UseCors(serviceConfig.ApiName) // .UseCors(serviceConfig.ClientName); if (env.IsDevelopment()) { loggerFactory.AddConsole(); app.UseDeveloperExceptionPage(); app.UseBrowserLink(); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseIdentityServer(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
// 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) { loggerFactory.AddNLog(); env.ConfigureNLog("nlog.config"); var logger = loggerFactory.CreateLogger(nameof(Startup)); app.UseStaticFiles(); if (env.IsDevelopment()) { logger.LogInformation("Development Mode"); app.UseDeveloperExceptionPage(); app.UseBrowserLink(); app.UseSimpleLogger(loggerFactory); app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(Directory.GetCurrentDirectory()), RequestPath = new PathString("") }); } else { logger.LogInformation("Production Mode"); app.UseExceptionHandler("/Home/Error"); } app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{*url}", defaults: new { controller = "Main", action = "Index" }); }); }
// 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, IApplicationLifetime appLifetime) { //loggerFactory.AddConsole(Configuration.GetSection("Logging")); //loggerFactory.AddDebug(); loggerFactory.AddNLog(); app.AddNLogWeb(); env.ConfigureNLog("nlog.config"); var jwtSettings = app.ApplicationServices.GetService <JwtSettings>(); app.UseJwtBearerAuthentication(new JwtBearerOptions { AutomaticAuthenticate = true, TokenValidationParameters = new TokenValidationParameters { ValidIssuer = jwtSettings.Issuer, ValidateAudience = false, IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtSettings.Key)) } }); MongoConfigurator.Initialize(); var generalSettings = app.ApplicationServices.GetService <GeneralSettings>(); if (generalSettings.SeedData) { var dataInitializer = app.ApplicationServices.GetService <IDataInitializer>(); dataInitializer.SeedAsync(); } app.UseMiddleware(typeof(ExceptionHandlingMiddleware)); app.UseMvc(); appLifetime.ApplicationStopped.Register(() => ApplicationContainer.Dispose()); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "WebApi"); }); } else { app.UseHsts(); } app.UseMiddleware <ActionMiddleware>(); env.ConfigureNLog("nlog.config"); loggerFactory.AddNLog(); app.UseHttpsRedirection(); 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) { // 注册Quartz定时任务 JobScheduler.Start(); app.UseCrystalQuartz(() => JobScheduler.scheduler); // CrystalQuartz任务调度地址:http://ip:port/quartz // 注册Nlog loggerFactory.AddNLog(); env.ConfigureNLog("nlog.config"); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.Run(async(context) => { await context.Response.WriteAsync("Hello World!"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // Microsoft.Extensions.Logging public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddNLog(); // app.AddNLogWeb(); env.ConfigureNLog("nlog.config"); loggerFactory.AddConsole(Configuration.GetSection("Logging")); // logging - filtered // loggerFactory.AddConsole((str, level) => { return level >= LogLevel.Trace; }); loggerFactory.AddDebug(); var log = loggerFactory.CreateLogger("Wu"); log.LogWarning("Haaaaa", "a", "aaaa"); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); // 使用IdentityServer app.UseIdentityServer(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
// 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, IApplicationLifetime appLifeTime) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } //var level = Configuration.GetSection("Logging:LogLevel:Default").GetValue<LogLevel>("Default"); //loggerFactory.AddConsole(level); //loggerFactory.AddDebug(level); //loggerFactory.AddEventSourceLogger(); loggerFactory.AddNLog(); env.ConfigureNLog("nlog.config"); app.UseAuthentication(); //app.UseHttpsRedirection(); SeedData(app); app.UseErrorHandler(); app.UseMvc(); appLifeTime.ApplicationStopped.Register(() => Container.Dispose()); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); var supportedCultures = new[] { new CultureInfo("es"), new CultureInfo("es-MX") }; app.UseRequestLocalization(new RequestLocalizationOptions { DefaultRequestCulture = new RequestCulture("es"), // Formatting numbers, dates, etc. SupportedCultures = supportedCultures, // UI strings that we have localized. SupportedUICultures = supportedCultures }); env.ConfigureNLog("nlog.config"); }