From 66e2cc683b660f09dfded772b99185f447d43da8 Mon Sep 17 00:00:00 2001 From: guotianliang <1265346495@qq.com> Date: Thu, 16 Jun 2022 16:55:42 +0800 Subject: [PATCH] sync auding long module --- .../ElasticsearchAuditLogManager.cs | 20 ++++++++++++------- .../Sanhe/Abp/AuditLogging/AuditLogAction.cs | 3 ++- .../README.md | 2 +- .../SerilogElasticsearchLoggingManager.cs | 6 ++++-- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/modules/auditing/Sanhe.Abp.AuditLogging.Elasticsearch/Sanhe/Abp/AuditLogging/Elasticsearch/ElasticsearchAuditLogManager.cs b/modules/auditing/Sanhe.Abp.AuditLogging.Elasticsearch/Sanhe/Abp/AuditLogging/Elasticsearch/ElasticsearchAuditLogManager.cs index 8701f07..8409b83 100644 --- a/modules/auditing/Sanhe.Abp.AuditLogging.Elasticsearch/Sanhe/Abp/AuditLogging/Elasticsearch/ElasticsearchAuditLogManager.cs +++ b/modules/auditing/Sanhe.Abp.AuditLogging.Elasticsearch/Sanhe/Abp/AuditLogging/Elasticsearch/ElasticsearchAuditLogManager.cs @@ -41,7 +41,6 @@ namespace Sanhe.Abp.AuditLogging.Elasticsearch Logger = NullLogger.Instance; } - public virtual async Task GetCountAsync( DateTime? startTime = null, DateTime? endTime = null, @@ -213,13 +212,20 @@ namespace Sanhe.Abp.AuditLogging.Elasticsearch var auditLog = await _converter.ConvertAsync(auditLogInfo); - var response = await client.IndexAsync( - auditLog, - (x) => x.Index(CreateIndex()) - .Id(auditLog.Id), - cancellationToken); + //var response = await client.IndexAsync( + // auditLog, + // (x) => x.Index(CreateIndex()) + // .Id(auditLog.Id), + // cancellationToken); + + // 使用 Bulk 命令传输可能存在参数庞大的日志结构 + var response = await client.BulkAsync( + dsl => dsl.Index(CreateIndex()) + .Create(ct => + ct.Id(auditLog.Id) + .Document(auditLog))); - return response.Id; + return response.Items?.FirstOrDefault()?.Id; } protected virtual List, QueryContainer>> BuildQueryDescriptor( diff --git a/modules/auditing/Sanhe.Abp.AuditLogging/Sanhe/Abp/AuditLogging/AuditLogAction.cs b/modules/auditing/Sanhe.Abp.AuditLogging/Sanhe/Abp/AuditLogging/AuditLogAction.cs index ea87620..1641b7f 100644 --- a/modules/auditing/Sanhe.Abp.AuditLogging/Sanhe/Abp/AuditLogging/AuditLogAction.cs +++ b/modules/auditing/Sanhe.Abp.AuditLogging/Sanhe/Abp/AuditLogging/AuditLogAction.cs @@ -41,7 +41,8 @@ namespace Sanhe.Abp.AuditLogging ExtraProperties = new ExtraPropertyDictionary(actionInfo.ExtraProperties); ServiceName = actionInfo.ServiceName; MethodName = actionInfo.MethodName; - Parameters = actionInfo.Parameters.Length > 2000 ? "" : actionInfo.Parameters; + Parameters = actionInfo.Parameters; + // Parameters = actionInfo.Parameters.Length > 2000 ? "" : actionInfo.Parameters; } } } diff --git a/modules/common/Sanhe.Abp.Hangfire.Storage.PostgreSql/README.md b/modules/common/Sanhe.Abp.Hangfire.Storage.PostgreSql/README.md index a10ad5e..dde3267 100644 --- a/modules/common/Sanhe.Abp.Hangfire.Storage.PostgreSql/README.md +++ b/modules/common/Sanhe.Abp.Hangfire.Storage.PostgreSql/README.md @@ -1,4 +1,4 @@ -# Sanhe.Abp.Hangfire.Dashboard +# Sanhe.Abp.Hangfire.Storage.PostgreSql Hangfire持久化PostgreSql diff --git a/modules/logging/Sanhe.Abp.Logging.Serilog.Elasticsearch/Sanhe/Abp/AuditLogging/Serilog/Elasticsearch/SerilogElasticsearchLoggingManager.cs b/modules/logging/Sanhe.Abp.Logging.Serilog.Elasticsearch/Sanhe/Abp/AuditLogging/Serilog/Elasticsearch/SerilogElasticsearchLoggingManager.cs index 63b33bd..3a4a187 100644 --- a/modules/logging/Sanhe.Abp.Logging.Serilog.Elasticsearch/Sanhe/Abp/AuditLogging/Serilog/Elasticsearch/SerilogElasticsearchLoggingManager.cs +++ b/modules/logging/Sanhe.Abp.Logging.Serilog.Elasticsearch/Sanhe/Abp/AuditLogging/Serilog/Elasticsearch/SerilogElasticsearchLoggingManager.cs @@ -91,7 +91,8 @@ namespace Sanhe.Abp.AuditLogging.Serilog.Elasticsearch (s) => s.Term( (t) => t.Field(GetField(nameof(SerilogInfo.Fields.UniqueId))).Value(id)), (s) => s.Term( - (t) => t.Field(GetField(nameof(SerilogInfo.Fields.TenantId))).Value(_currentTenant.GetId()))))), + (t) => t.Field(GetField(nameof(SerilogInfo.Fields.TenantId))).Value(_currentTenant.GetId()))))) + .Size(1), cancellationToken); } else @@ -118,7 +119,8 @@ namespace Sanhe.Abp.AuditLogging.Serilog.Elasticsearch (q) => q.Bool( (b) => b.Must( (s) => s.Term( - (t) => t.Field(GetField(nameof(SerilogInfo.Fields.UniqueId))).Value(id))))), + (t) => t.Field(GetField(nameof(SerilogInfo.Fields.UniqueId))).Value(id))))) + .Size(1), cancellationToken); }