当前位置: 首页>>代码示例>>C#>>正文


C# IApplicationBuilder.UseRequestLogger方法代码示例

本文整理汇总了C#中IApplicationBuilder.UseRequestLogger方法的典型用法代码示例。如果您正苦于以下问题:C# IApplicationBuilder.UseRequestLogger方法的具体用法?C# IApplicationBuilder.UseRequestLogger怎么用?C# IApplicationBuilder.UseRequestLogger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IApplicationBuilder的用法示例。


在下文中一共展示了IApplicationBuilder.UseRequestLogger方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConfigureTraceLogging

        public void ConfigureTraceLogging(IApplicationBuilder app,
            ILoggerFactory loggerFactory)
        {
            loggerFactory.MinimumLevel = LogLevel.Debug;

#if DNX451
            var sourceSwitch = new SourceSwitch("LoggingSample");
            sourceSwitch.Level = SourceLevels.Critical;
            loggerFactory.AddTraceSource(sourceSwitch,
                new ConsoleTraceListener(false));
            loggerFactory.AddTraceSource(sourceSwitch, 
                new EventLogTraceListener("Application"));
#endif

            app.UseRequestLogger();

            app.Run(async context =>
            {
                if (context.Request.Path.Value.Contains("boom"))
                {
                    throw new Exception("boom!");
                }
                await context.Response.WriteAsync("Hello World!");
            });
        }
开发者ID:ronikurnia1,项目名称:Docs,代码行数:25,代码来源:Startup.cs

示例2: ConfigureLogMiddleware

        public void ConfigureLogMiddleware(IApplicationBuilder app, 
            ILoggerFactory loggerfactory)
        {
            loggerfactory.AddConsole(minLevel: LogLevel.Information);

            app.UseRequestLogger();

            app.Run(async context =>
            {
                await context.Response.WriteAsync("Hello from " + _environment);
            });
        }
开发者ID:bigfont,项目名称:Docs,代码行数:12,代码来源:Startup.cs

示例3: ConfigureLogMiddleware

        public void ConfigureLogMiddleware(IApplicationBuilder app,
            ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(minLevel: LogLevel.Debug);
            app.UseRequestLogger();

            app.Run(async context =>
            {
                if (context.Request.Path.Value.Contains("boom"))
                {
                    throw new Exception("boom!");
                }
                await context.Response.WriteAsync("Hello World!");
            });
        }
开发者ID:ronikurnia1,项目名称:Docs,代码行数:15,代码来源:Startup.cs

示例4: Configure

		// Configure is called after ConfigureServices is called.
		public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
		{
			loggerFactory.MinimumLevel = LogLevel.Information;
			loggerFactory.AddConsole();
			loggerFactory.AddDebug();

			// Configure the HTTP request pipeline.

			// Add the following to the request pipeline only in development environment.
			if (env.IsDevelopment())
			{
				app.UseBrowserLink();
				app.UseErrorPage();
			}
			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();

			app.UseRequestLogger();

			// Use prerender middleware
			app.UsePrerender();

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

							// Uncomment the following line to add a route for porting Web API 2 controllers.
							// routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}");
						});
		}
开发者ID:OndrejValenta,项目名称:prerender.io.mvc6,代码行数:41,代码来源:Startup.cs

示例5: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.MinimumLevel = LogLevel.Information;
            loggerFactory.AddConsole(minLevel: LogLevel.Information);
            loggerFactory.AddDebug();

            var logger = loggerFactory.CreateLogger(env.EnvironmentName);

            app.UseRequestLogger();

            app.MapWhen(context =>
            {
                return context.Request.Query.ContainsKey("branch");
            }, HandleBranch);

            app.Run(async context =>
            {
                context.Response.ContentType = "text/plain";

                await context.Response.WriteAsync("Hello from " + env.EnvironmentName);
            });
        }
开发者ID:serveryang,项目名称:UniformUIKit,代码行数:22,代码来源:Startup.cs

示例6: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseCors(builder =>
            {
                builder.AllowAnyHeader();
                builder.AllowAnyMethod();
                builder.AllowAnyOrigin();
                builder.AllowCredentials();
            });

            // use custom middleware
            app.UseRequestLogger();

            app.UseAldeloAuthentication(configureOptions: option =>
            {
                // if false, you have to explicitly point out what AuthenticationScheme in [Authorize]
                // like '[Authorize(ActiveAuthenticationSchemes ="Bearer")]'
                option.AutomaticAuthenticate = true;

                // Challenge will be shown in request header, as default 'WWW-Authenticate: Aldelo.Passport'
                // if false, cannot enter AldeloAuthenticationHandler code, will return 401 directly
                option.AutomaticChallenge = true;

                // if you want to validate below:
                // security key (for signature), lifetime, audience and issuer
                // these 4 field default value is true
                option.TokenValidationParameters.RequireSignedTokens = true;
                option.TokenValidationParameters.ValidateSignature = true;
                option.TokenValidationParameters.IssuerSigningKey = Utils.SecurityKey;

                option.TokenValidationParameters.ValidateLifetime = true;

                option.TokenValidationParameters.ValidateIssuer = true;
                option.TokenValidationParameters.ValidIssuer = "isu:aldelo.security";

                option.TokenValidationParameters.ValidateAudience = true;
                option.TokenValidationParameters.ValidAudience = "aud:aldelo.cloud";
                /* custom the audience validator
                option.TokenValidationParameters.AudienceValidator = (audi, security, vp) =>
                {
                    foreach (var s in audi)
                    {
                        if (s == "aud:aldelo.cloud")
                        {
                            return true;
                        }
                    }

                    return false;
                };
                */

                // process events
                option.Events = new JwtBearerEvents()
                {
                    OnChallenge = (context) =>
                    {
                        return Task.FromResult(false);
                    },
                    OnReceivedToken = (context) =>
                    {
                        return Task.FromResult(false);
                    },
                    OnValidatedToken = (context) =>
                    {
                        // give him 'BossClaim' for authorization policy
                        //context.AuthenticationTicket.Principal.AddIdentity(new ClaimsIdentity(new List<Claim> { new Claim("BossClaim", "I'm boss") }));

                        return Task.FromResult(false);
                    },
                    OnAuthenticationFailed = (context) =>
                    {
                        return Task.FromResult(false);
                    }
                };

                // if we want a validator instead of default one
                //option.SecurityTokenValidators = new List<ISecurityTokenValidator>() { new BlobTokenValidator() };
            });

            app.UseMvc();
        }
开发者ID:yao-bin,项目名称:TinyMVC6,代码行数:82,代码来源:Startup.cs


注:本文中的IApplicationBuilder.UseRequestLogger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。