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


C# ILoggerFactory.WithFilter方法代码示例

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


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

示例1: Configure

        public void Configure(IApplicationBuilder app,
            IHostingEnvironment env,
            ILoggerFactory loggerFactory)
        {
            loggerFactory
                .WithFilter(new FilterLoggerSettings
                {
                    { "Microsoft", LogLevel.Warning },
                    { "System", LogLevel.Warning },
                    { "ToDoApi", LogLevel.Debug }
                })
                .AddConsole();

            // add Trace Source logging
            var testSwitch = new SourceSwitch("sourceSwitch", "Logging Sample");
            testSwitch.Level = SourceLevels.Warning;
            loggerFactory.AddTraceSource(testSwitch,
                new TextWriterTraceListener(writer: Console.Out));

            app.UseStaticFiles();

            app.UseMvc();

            // Create a catch-all response
            app.Run(async (context) =>
            {
                if (context.Request.Path.Value.Contains("boom"))
                {
                    throw new Exception("boom!");
                }
                var logger = loggerFactory.CreateLogger("Catchall Endpoint");
                logger.LogInformation("No endpoint found for request {path}", context.Request.Path);
                await context.Response.WriteAsync("No endpoint found - try /api/todo.");
            });
        }
开发者ID:ColinDabritz,项目名称:Docs,代码行数:35,代码来源:Startup.cs

示例2: Configure

        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            loggerFactory
                .WithFilter(new FilterLoggerSettings
                {
                    {"Microsoft", LogLevel.Information},
                    {"System", LogLevel.Information},
                    {"DoingGood", LogLevel.Debug}
                })
                .AddConsole()
                .AddDebug();

            app.Map("/_ah", sub =>
            {
                sub.Run(HealthCheck.Run);
            });

            app.UseDefaultFiles();

            app.UseMiddleware<ReverseProxySupportMiddleware>();
            app.UseMiddleware<RequestLoggerMiddleware>();
            app.UseProfiling();

            app.UseStaticFiles(new StaticFileOptions
            {
                OnPrepareResponse = context =>
                {
                    if (context.Context.Request.Path.StartsWithSegments(new PathString("/app")))
                    {
                        context.Context.Response.Headers["Cache-Control"] = "no-cache, no-store";
                        context.Context.Response.Headers["Pragma"] = "no-cache";
                        context.Context.Response.Headers["Expires"] = "-1";
                    }
                }
            });

            app.Map("/signup", SignUpMiddleware.CreateOrganization);

            app.UseMultitenancy<Organization>();

            app.UsePerTenant<Organization>((tenant, pipeline) => {
                pipeline.Map("/" + tenant.Tenant.Slug, subApp => {
                    subApp.ConfigureAuthentication();
                    subApp.UseMvc();
                });
            });
        }
开发者ID:HopeNB,项目名称:web,代码行数:47,代码来源:Startup.cs


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