修改日志输出测试
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Serilog;
|
||||
using DocumentFormat.OpenXml.Bibliography;
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
using Serilog.Formatting.Compact;
|
||||
|
||||
@@ -28,12 +29,14 @@ namespace IRaCIS.Core.API
|
||||
.Enrich.FromLogContext()
|
||||
.Filter.ByExcluding(logEvent => logEvent.Properties.ContainsKey("RequestPath") && logEvent.Properties["RequestPath"].ToString().Contains("/health"))
|
||||
|
||||
//https://github.com/serilog/serilog-formatting-compact
|
||||
// 控制台输出 JSON 格式
|
||||
.WriteTo.Console(formatter: new CompactJsonFormatter(),LogEventLevel.Warning)
|
||||
//https://github.com/serilog/serilog-formatting-compact
|
||||
|
||||
// 文件输出 JSON 格式
|
||||
.WriteTo.File(new CompactJsonFormatter(), $"{AppContext.BaseDirectory}Serilogs/.json", rollingInterval: RollingInterval.Day);
|
||||
.WriteTo.Console()
|
||||
.WriteTo.File($"{AppContext.BaseDirectory}Serilogs/.log", rollingInterval: RollingInterval.Day);
|
||||
//// 控制台输出 JSON 格式
|
||||
//.WriteTo.Console(formatter: new CompactJsonFormatter(), LogEventLevel.Warning),
|
||||
//// 文件输出 JSON 格式
|
||||
//.WriteTo.File(new CompactJsonFormatter(), $"{AppContext.BaseDirectory}Serilogs/.json", rollingInterval: RollingInterval.Day);
|
||||
|
||||
////控制台 方便调试 问题 我们显示记录日志 时 获取上下文的ip 和用户名 用户类型
|
||||
//.WriteTo.Console(restrictedToMinimumLevel: LogEventLevel.Warning,
|
||||
|
||||
Reference in New Issue
Block a user