本文整理汇总了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.");
});
}
示例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();
});
});
}