控制台应用程序项目..在我的代码中,我想从控制台隐藏错误,如何在不隐藏信息和警告的情况下做到这一点
return logger.MinimumLevel.Verbose()
.MinimumLevel.Override("Microsoft", LogEventLevel.Verbose)
.Filter.ByIncludingOnly(Serilog.Filters.Matching.FromSource<Transformer>())
.Enrich.FromLogContext()
.WriteTo.Console(LogEventLevel.Information)
.WriteTo.Async(config => config.File(Path.Combine(logsPath, runId + "-logFileName.log"),
rollOnFileSizeLimit: true,
fileSizeLimitBytes: 314572800));
答案 0 :(得分:1)
return logger.MinimumLevel.Verbose()
.MinimumLevel.Override("Microsoft", LogEventLevel.Verbose)
.Filter.ByIncludingOnly(Serilog.Filters.Matching.FromSource<Transformer>())
.Enrich.FromLogContext()
.WriteTo.Logger(lc => lc
.Filter.ByIncludingOnly(le => le.Level == LogEventLevel.Information || le.Level == LogEventLevel.Warning)
.WriteTo.Console(LogEventLevel.Information))
.WriteTo.Async(config =>
config.File(
Path.Combine(logsPath, runId + "-logFileName.log"),
rollOnFileSizeLimit: true,
fileSizeLimitBytes: 314572800));