Ver código fonte

Merge branch 'master' of http://git.fwt.com/Hotline/hotline

TANG JIANG 2 anos atrás
pai
commit
1733aefd36

+ 0 - 2
src/Hotline.Api/Hotline.Api.csproj

@@ -9,14 +9,12 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="Exceptionless.AspNetCore" Version="4.8.0" />
     <PackageReference Include="FluentValidation.AspNetCore" Version="11.2.2" />
     <PackageReference Include="IdentityModel" Version="6.0.0" />
     <PackageReference Include="Mapster.DependencyInjection" Version="1.0.0" />
     <PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.1.0" />
     <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.10" />
     <PackageReference Include="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Version="6.0.8" />
-    <PackageReference Include="Serilog.Sinks.Exceptionless" Version="3.1.5" />
     <PackageReference Include="Serilog.Sinks.Grafana.Loki" Version="8.1.0" />
     <PackageReference Include="Serilog.Sinks.MongoDB" Version="5.3.1" />
     <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />

+ 5 - 9
src/Hotline.Api/StartupExtensions.cs

@@ -1,6 +1,5 @@
 using System.IdentityModel.Tokens.Jwt;
 using System.Reflection;
-using Exceptionless;
 using FluentValidation;
 using FluentValidation.AspNetCore;
 using Hotline.Api.Realtimes;
@@ -110,9 +109,6 @@ internal static class StartupExtensions
         })
             .AddValidatorsFromAssembly(typeof(AppContractsStartupExtensions).Assembly);
 
-        //ex log
-        services.AddExceptionless(configuration);
-
         services.AddSingleton<IAuthorizationPolicyProvider, AuthorizationPolicyProvider>();
         services.AddSingleton<IAuthorizationHandler, PermissionHandler>();
 
@@ -123,11 +119,11 @@ internal static class StartupExtensions
     {
         app.UseSerilogRequestLogging();
 
-        var useExless = app.Configuration.GetSection("Exceptionless:InUse").Get<bool>();
-        if (useExless)
-        {
-            app.UseExceptionless();
-        }
+        //var useExless = app.Configuration.GetSection("Exceptionless:InUse").Get<bool>();
+        //if (useExless)
+        //{
+        //    app.UseExceptionless();
+        //}
 
         var swaggerEnable = app.Configuration.GetSection("Swagger").Get<bool>();
         // Configure the HTTP request pipeline.

+ 14 - 8
src/Hotline.Api/appsettings.Development.json

@@ -3,7 +3,7 @@
     "Using": [
       "Serilog.Enrichers.Span",
       "Serilog.Sinks.Console",
-      "Serilog.Sinks.Exceptionless"
+      "Serilog.Sinks.Grafana.Loki"
     ],
     "MinimumLevel": {
       "Default": "Information",
@@ -26,16 +26,22 @@
           "theme": "Serilog.Sinks.SystemConsole.Themes.ConsoleTheme::None, Serilog.Sinks.Console"
         }
       },
-      {
-        "Name": "Exceptionless"
-      }
       //{
-      //  "Name": "File",
+      //  "Name": "GrafanaLoki",
       //  "Args": {
-      //    "path": "logs/log-.txt",
-      //    "rollingInterval": "Day"
+      //    "outputTemplate": "[{Timestamp:HH:mm:ss} {Level}] {SourceContext} [{TraceId}]{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}",
+      //    "uri": "http://192.168.100.217:3100",
+      //    "labels": [
+      //      {
+      //        "key": "app",
+      //        "value": "hotline"
+      //      }
+      //    ],
+      //    "propertiesAsLabels": [
+      //      "fwhl"
+      //    ]
       //  }
-      //},
+      //}
     ],
     "Enrich": [ "FromLogContext", "WithSpan" ]
   },

+ 28 - 12
src/Hotline.Api/appsettings.json

@@ -3,7 +3,7 @@
     "Using": [
       "Serilog.Enrichers.Span",
       "Serilog.Sinks.Console",
-      "Serilog.Sinks.Exceptionless"
+      "Serilog.Sinks.Grafana.Loki"
     ],
     "MinimumLevel": {
       "Default": "Information",
@@ -26,6 +26,22 @@
           "theme": "Serilog.Sinks.SystemConsole.Themes.ConsoleTheme::None, Serilog.Sinks.Console"
         }
       },
+      {
+        "Name": "GrafanaLoki",
+        "Args": {
+          "outputTemplate": "[{Timestamp:HH:mm:ss} {Level}] {SourceContext} [{TraceId}]{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}",
+          "uri": "http://192.168.100.217:3100",
+          "labels": [
+            {
+              "key": "app",
+              "value": "hotline"
+            }
+          ],
+          "propertiesAsLabels": [
+            "fwhl"
+          ]
+        }
+      }
       //{
       //  "Name": "Exeptionless",
       //  "Args": {
@@ -41,17 +57,17 @@
       //    "rollingInterval": "Day"
       //  }
       //},
-      {
-        "Name": "MongoDBBson",
-        "Args": {
-          "databaseUrl": "mongodb://192.168.100.121:27017/hotline_logs",
-          "collectionName": "logs",
-          "cappedMaxSizeMb": "1024",
-          "cappedMaxDocuments": "50000",
-          "rollingInterval": "Day",
-          "outputTemplate": "[{Timestamp:HH:mm:ss} {Level}] {SourceContext} [{TraceId}]{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}"
-        }
-      }
+      //{
+      //  "Name": "MongoDBBson",
+      //  "Args": {
+      //    "databaseUrl": "mongodb://192.168.100.121:27017/hotline_logs",
+      //    "collectionName": "logs",
+      //    "cappedMaxSizeMb": "1024",
+      //    "cappedMaxDocuments": "50000",
+      //    "rollingInterval": "Day",
+      //    "outputTemplate": "[{Timestamp:HH:mm:ss} {Level}] {SourceContext} [{TraceId}]{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}"
+      //  }
+      //}
     ],
     "Enrich": [ "FromLogContext", "WithSpan" ]
   },

+ 1 - 1
src/Hotline.Repository.SqlSugar/Extensions/SqlSugarStartupExtensions.cs

@@ -172,7 +172,7 @@ namespace Hotline.Repository.SqlSugar.Extensions
             /***写AOP等方法***/
             db.Aop.OnLogExecuting = (sql, pars) =>
             {
-                Log.Information(sql);
+                //Log.Information(sql);
             };
             db.Aop.OnError = (exp) =>//SQL报错
             {