清理多余引用
continuous-integration/drone/push Build is passing

This commit is contained in:
hang
2024-10-13 16:31:09 +08:00
parent 0206947202
commit e65227c7bf
43 changed files with 419 additions and 507 deletions
@@ -1,14 +1,11 @@
using IRaCIS.Core.Infrastructure;
using IRaCIS.Core.Infrastructure.Extention;
using IRaCIS.Core.Domain.Share;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Serilog.Core;
using Serilog.Events;
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using IRaCIS.Core.Domain.Share;
namespace IRaCIS.Core.API
{
@@ -25,7 +22,7 @@ namespace IRaCIS.Core.API
_serviceProvider = serviceProvider;
if (enrichAction == null)
{
_enrichAction = (logEvent, propertyFactory, httpContext) =>
_enrichAction = (logEvent, propertyFactory, httpContext) =>
{
logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("RequestIP", httpContext.Connection.RemoteIpAddress.ToString()));
@@ -73,7 +70,7 @@ namespace IRaCIS.Core.API
// Reset the request's body stream position for next middleware in the pipeline.
request.Body.Position = 0;
return requestBody==null?String.Empty: requestBody.Trim();
return requestBody == null ? String.Empty : requestBody.Trim();
}
private async Task<string> ReadResponseBody(HttpResponse response)
@@ -1,9 +1,7 @@
using Microsoft.AspNetCore.Builder;
using Serilog;
using Serilog;
using Serilog.Events;
//using Serilog.Sinks.Email;
using System;
using System.Net;
namespace IRaCIS.Core.API
{
@@ -16,13 +14,13 @@ namespace IRaCIS.Core.API
var config = new LoggerConfiguration()
.MinimumLevel.Information()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
// Filter out ASP.NET Core infrastructre logs that are Information and below 日志太多了 一个请求 记录好几条
// Filter out ASP.NET Core infrastructre logs that are Information and below 日志太多了 一个请求 记录好几条
.MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning)
.MinimumLevel.Override("Hangfire", LogEventLevel.Warning)
.MinimumLevel.Override("System.Net.Http.HttpClient.HttpReports", LogEventLevel.Warning)
.MinimumLevel.Override("System.Net.Http.HttpClient.HttpReports", LogEventLevel.Warning)
.Enrich.WithClientIp()
.Enrich.FromLogContext()
.Filter.ByExcluding(logEvent =>logEvent.Properties.ContainsKey("RequestPath") && logEvent.Properties["RequestPath"].ToString().Contains("/health"))
.Filter.ByExcluding(logEvent => logEvent.Properties.ContainsKey("RequestPath") && logEvent.Properties["RequestPath"].ToString().Contains("/health"))
//控制台 方便调试 问题 我们显示记录日志 时 获取上下文的ip 和用户名 用户类型
.WriteTo.Console(restrictedToMinimumLevel: LogEventLevel.Warning,