修改日志输出测试

IRC_NewDev
hang 2024-10-21 18:02:35 +08:00
parent 48ff2a347e
commit 823f082396
3 changed files with 10 additions and 12 deletions

View File

@ -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,

View File

@ -57,6 +57,7 @@ public class ProjectExceptionFilter(ILogger<ProjectExceptionFilter> _logger, ISt
_logger.LogError(errorInfo);
//_logger.LogError(exception, exception.Message);
}
else
{

View File

@ -33,12 +33,6 @@ using System.Text;
namespace IRaCIS.Core.Application.Service
{
[ApiExplorerSettings(GroupName = "Institution")]
public class TestService(IRepository<Dictionary> _dicRepository,
IRepository<Trial> _trialRepository,