diff --git a/IRaCIS.Core.API/_PipelineExtensions/Serilog/SerilogConfig.cs b/IRaCIS.Core.API/_PipelineExtensions/Serilog/SerilogConfig.cs index c5aab64f1..af2326ab3 100644 --- a/IRaCIS.Core.API/_PipelineExtensions/Serilog/SerilogConfig.cs +++ b/IRaCIS.Core.API/_PipelineExtensions/Serilog/SerilogConfig.cs @@ -19,7 +19,7 @@ namespace IRaCIS.Core.API app.UseSerilogRequestLogging(opts => { - opts.MessageTemplate = "{TokenUserRealName} {TokenUserType} {ClientIp} {RequestIP} {Host} {Protocol} {RequestMethod} {RequestPath} {RequestBody} responded {StatusCode} in {Elapsed:0.0000} ms"; + opts.MessageTemplate = "{TokenUserRealName} {TokenUserType} {ClientIp} {LocalIP} {Host} {Protocol} {RequestMethod} {RequestPath} {RequestBody} responded {StatusCode} in {Elapsed:0.0000} ms"; opts.EnrichDiagnosticContext = SerilogHelper.EnrichFromRequest; }); diff --git a/IRaCIS.Core.API/_PipelineExtensions/Serilog/SerilogHelper.cs b/IRaCIS.Core.API/_PipelineExtensions/Serilog/SerilogHelper.cs index 1bb30e7bd..a5523833c 100644 --- a/IRaCIS.Core.API/_PipelineExtensions/Serilog/SerilogHelper.cs +++ b/IRaCIS.Core.API/_PipelineExtensions/Serilog/SerilogHelper.cs @@ -20,7 +20,7 @@ namespace IRaCIS.Core.API diagnosticContext.Set("Host", request.Host); //这种获取的Ip不准 配置服务才行 - diagnosticContext.Set("RequestIP", httpContext.Connection.RemoteIpAddress.ToString()); + //diagnosticContext.Set("RequestIP", httpContext.Connection.RemoteIpAddress.ToString()); //这种方式可以,但是serilog提供了 就不用了 //diagnosticContext.Set("TestIP", httpContext.GetUserIp()); diff --git a/IRaCIS.Core.API/_ServiceExtensions/Serilog/SerilogSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/Serilog/SerilogSetup.cs index a27de1505..eb8c6752e 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/Serilog/SerilogSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/Serilog/SerilogSetup.cs @@ -26,9 +26,11 @@ namespace IRaCIS.Core.API //控制台 方便调试 问题 我们显示记录日志 时 获取上下文的ip 和用户名 用户类型 .WriteTo.Console(restrictedToMinimumLevel: LogEventLevel.Warning, - outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3} ] {LocalIP} {ClientIp} {TokenUserRealName} {TokenUserType} {Message:lj} {Properties:j}{NewLine} {Exception}") + outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3} ] {LocalIP} {ClientIp} {TokenUserRealName} {TokenUserType} {Message:lj} {Properties:j}{NewLine} {Exception}") + .WriteTo.File($"{AppContext.BaseDirectory}Serilogs/.log", rollingInterval: RollingInterval.Day, outputTemplate: "{Timestamp:HH:mm:ss} || {Level} || {SourceContext:l} || {Message} ||{Exception} ||end {NewLine}"); + //.WriteTo.MSSqlServer("Data Source=DESKTOP-4TU9A6M;Initial Catalog=CoreFrame;User ID=sa;Password=123456", "logs", autoCreateSqlTable: true, restrictedToMinimumLevel: LogEventLevel.Information)//从左至右四个参数分别是数据库连接字符串、表名、如果表不存在是否创建、最低等级。Serilog会默认创建一些列。 if (environment == "Production") diff --git a/IRaCIS.Core.API/appsettings.Test_IRC.json b/IRaCIS.Core.API/appsettings.Test_IRC.json index 414fd04bd..15820fa89 100644 --- a/IRaCIS.Core.API/appsettings.Test_IRC.json +++ b/IRaCIS.Core.API/appsettings.Test_IRC.json @@ -18,7 +18,7 @@ "AliyunOSS": { "regionId": "cn-shanghai", - "endpoint": "https://oss-cn-shanghai.aliyuncs.com", + "endPoint": "https://oss-cn-shanghai.aliyuncs.com", "accessKeyId": "LTAI5tKvzs7ed3UfSpNk3xwQ", "accessKeySecret": "zTIceGEShlZDGnLrCFfIGFE7TXVRio", "bucketName": "zy-irc-test-store", @@ -28,7 +28,7 @@ }, "MinIO": { - "endpoint": "192.168.3.68", + "endPoint": "192.168.3.68", "port": "8001", "useSSL": false, "accessKey": "IDFkwEpWej0b4DtiuThL", @@ -37,7 +37,7 @@ }, "AWS": { - "endpoint": "s3.us-east-1.amazonaws.com", + "endPoint": "s3.us-east-1.amazonaws.com", "useSSL": false, "accessKey": "AKIAZQ3DRSOHFPJJ6FEU", "secretKey": "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", diff --git a/IRaCIS.Core.Application/Helper/OSSService.cs b/IRaCIS.Core.Application/Helper/OSSService.cs index 0c83e50e1..1e257788e 100644 --- a/IRaCIS.Core.Application/Helper/OSSService.cs +++ b/IRaCIS.Core.Application/Helper/OSSService.cs @@ -27,7 +27,7 @@ namespace IRaCIS.Core.Application.Helper public class AWSOptions { - public string endpoint { get; set; } + public string endPoint { get; set; } public bool useSSL { get; set; } public string accessKey { get; set; } public string secretKey { get; set; } @@ -152,7 +152,7 @@ namespace IRaCIS.Core.Application.Helper var minIOConfig = ObjectStoreServiceOptions.MinIO; - var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endpoint}:{minIOConfig.port}") + var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}:{minIOConfig.port}") .WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL) .Build(); @@ -168,7 +168,7 @@ namespace IRaCIS.Core.Application.Helper var minIOConfig = ObjectStoreServiceOptions.AWS; - var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endpoint}") + var minioClient = new MinioClient().WithEndpoint($"{minIOConfig.endPoint}") .WithCredentials(minIOConfig.accessKey, minIOConfig.secretKey).WithSSL(minIOConfig.useSSL) .Build();