Answer the question
In order to leave comments, you need to log in
Filters in serilog?
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Override("Microsoft", LogEventLevel.Debug)
.Enrich.FromLogContext()
.Filter.ByIncludingOnly("@Level is null")
.WriteTo.Console()
.CreateLogger();
.Filter.ByIncludingOnly(a => a.Level == LogEventLevel.Information)
Answer the question
In order to leave comments, you need to log in
Connected Serilog.Expressions, and read docks from Serilog.Filter.Expressions.
muddler
You are asking to be sorted out for you in the current code. It's better to describe the problem you are trying to solve.
I didn't understand what you want from the question either.
I found this code in my stash, maybe it will help you, there is nothing in the config, everything is through the code:
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.File("info.txt", LogEventLevel.Information)
//.WriteTo.File("debug.txt", LogEventLevel.Debug)
.WriteTo.Console(LogEventLevel.Information, theme: SystemConsoleTheme.Colored)
.CreateLogger();
private static void ConfigureServices(IServiceCollection services, IExternalServerSettings serverSettings)
{
......
services.AddLogging(lb =>
{
lb.SetMinimumLevel(LogLevel.Debug);
lb.AddFilter((type, level) => !type.Contains("System"));
});
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question