更新时间:2022-06-09 01:34:27
您无法使用 MinimumLevel
作为 @barbsan 注释来实现它.
You cannot achieve it using MinimumLevel
as @barbsan comment.
但是您可以使用过滤来处理您的情况.
But you can use filtering for in your case.
过滤器只是对 LogEvent
_logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.File(_filepath)
.Filter.ByIncludingOnly(isNotInfoLevel)
.CreateLogger();
在下面的函数中,您可以根据需要添加更多条件
And in below function you can add more conditions if needed
private static bool isNotInfoLevel(LogEvent le)
{
return le.Level != LogEventLevel.Information;
}
使用ByExclusion
排除信息层的另一种方法
Anther way by using ByExcluding
to exclude information level
.Filter.ByExcluding((le) => le.Level == LogEventLevel.Information)