feat: add logging to Seq

This commit is contained in:
spiral 2022-12-03 11:49:19 +00:00
parent fbd036e9c4
commit 026a822c74
No known key found for this signature in database
GPG Key ID: 244A11E4B0BCF40E
5 changed files with 96 additions and 70 deletions

View File

@ -608,8 +608,8 @@
},
"Serilog": {
"type": "Transitive",
"resolved": "2.10.0",
"contentHash": "+QX0hmf37a0/OZLxM3wL7V6/ADvC1XihXN4Kq/p6d8lCPfgkRdiuhbWlMaFjR9Av0dy5F0+MBeDmDdRZN/YwQA=="
"resolved": "2.12.0",
"contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg=="
},
"Serilog.Extensions.Logging": {
"type": "Transitive",
@ -681,23 +681,29 @@
},
"Serilog.Sinks.File": {
"type": "Transitive",
"resolved": "4.1.0",
"contentHash": "U0b34w+ZikbqWEZ3ui7BdzxY/19zwrdhLtI3o6tfmLdD3oXxg7n2TZJjwCCTlKPgRuYic9CBWfrZevbb70mTaw==",
"resolved": "5.0.0",
"contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==",
"dependencies": {
"Serilog": "2.5.0",
"System.IO.FileSystem": "4.0.1",
"System.Text.Encoding.Extensions": "4.0.11",
"System.Threading.Timer": "4.0.1"
"Serilog": "2.10.0"
}
},
"Serilog.Sinks.PeriodicBatching": {
"type": "Transitive",
"resolved": "2.1.1",
"contentHash": "L1iZtcEzQdEIYCPvhYJYB2RofPg+i1NhHJfS+DpXLyLSMS6OXebqaI1fxWhmJRIjD9D9BuXi23FkZTQDiP7cHw==",
"resolved": "3.1.0",
"contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==",
"dependencies": {
"Serilog": "2.0.0",
"System.Collections.Concurrent": "4.0.12",
"System.Threading.Timer": "4.0.1"
"Serilog": "2.0.0"
}
},
"Serilog.Sinks.Seq": {
"type": "Transitive",
"resolved": "5.2.2",
"contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==",
"dependencies": {
"Serilog": "2.12.0",
"Serilog.Formatting.Compact": "1.1.0",
"Serilog.Sinks.File": "5.0.0",
"Serilog.Sinks.PeriodicBatching": "3.1.0"
}
},
"SqlKata": {
@ -1520,51 +1526,52 @@
"myriad": {
"type": "Project",
"dependencies": {
"Google.Protobuf": "3.13.0",
"Grpc.Net.ClientFactory": "2.32.0",
"Polly": "7.2.1",
"Polly.Contrib.WaitAndRetry": "1.1.1",
"Serilog": "2.10.0",
"StackExchange.Redis": "2.2.88",
"System.Linq.Async": "5.0.0"
"Google.Protobuf": "[3.13.0, )",
"Grpc.Net.ClientFactory": "[2.32.0, )",
"Polly": "[7.2.1, )",
"Polly.Contrib.WaitAndRetry": "[1.1.1, )",
"Serilog": "[2.10.0, )",
"StackExchange.Redis": "[2.2.88, )",
"System.Linq.Async": "[5.0.0, )"
}
},
"pluralkit.core": {
"type": "Project",
"dependencies": {
"App.Metrics": "4.1.0",
"App.Metrics.Reporting.InfluxDB": "4.1.0",
"Autofac": "6.0.0",
"Autofac.Extensions.DependencyInjection": "7.1.0",
"Dapper": "2.0.35",
"Dapper.Contrib": "2.0.35",
"Google.Protobuf": "3.13.0",
"Microsoft.Extensions.Caching.Memory": "3.1.10",
"Microsoft.Extensions.Configuration": "3.1.10",
"Microsoft.Extensions.Configuration.Binder": "3.1.10",
"Microsoft.Extensions.Configuration.CommandLine": "3.1.10",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "3.1.10",
"Microsoft.Extensions.Configuration.Json": "3.1.10",
"Microsoft.Extensions.DependencyInjection": "3.1.10",
"Microsoft.Extensions.Logging": "3.1.10",
"Newtonsoft.Json": "12.0.3",
"NodaTime": "3.0.3",
"NodaTime.Serialization.JsonNet": "3.0.0",
"Npgsql": "4.1.5",
"Npgsql.NodaTime": "4.1.5",
"Serilog": "2.10.0",
"Serilog.Extensions.Logging": "3.0.1",
"Serilog.Formatting.Compact": "1.1.0",
"Serilog.NodaTime": "3.0.0",
"Serilog.Sinks.Async": "1.4.1-dev-00071",
"Serilog.Sinks.Console": "4.0.0-dev-00834",
"Serilog.Sinks.Elasticsearch": "8.4.1",
"Serilog.Sinks.File": "4.1.0",
"SqlKata": "2.3.7",
"SqlKata.Execution": "2.3.7",
"StackExchange.Redis": "2.2.88",
"System.Interactive.Async": "5.0.0",
"ipnetwork2": "2.5.381"
"App.Metrics": "[4.1.0, )",
"App.Metrics.Reporting.InfluxDB": "[4.1.0, )",
"Autofac": "[6.0.0, )",
"Autofac.Extensions.DependencyInjection": "[7.1.0, )",
"Dapper": "[2.0.35, )",
"Dapper.Contrib": "[2.0.35, )",
"Google.Protobuf": "[3.13.0, )",
"Microsoft.Extensions.Caching.Memory": "[3.1.10, )",
"Microsoft.Extensions.Configuration": "[3.1.10, )",
"Microsoft.Extensions.Configuration.Binder": "[3.1.10, )",
"Microsoft.Extensions.Configuration.CommandLine": "[3.1.10, )",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "[3.1.10, )",
"Microsoft.Extensions.Configuration.Json": "[3.1.10, )",
"Microsoft.Extensions.DependencyInjection": "[3.1.10, )",
"Microsoft.Extensions.Logging": "[3.1.10, )",
"Newtonsoft.Json": "[12.0.3, )",
"NodaTime": "[3.0.3, )",
"NodaTime.Serialization.JsonNet": "[3.0.0, )",
"Npgsql": "[4.1.5, )",
"Npgsql.NodaTime": "[4.1.5, )",
"Serilog": "[2.12.0, )",
"Serilog.Extensions.Logging": "[3.0.1, )",
"Serilog.Formatting.Compact": "[1.1.0, )",
"Serilog.NodaTime": "[3.0.0, )",
"Serilog.Sinks.Async": "[1.4.1-dev-00071, )",
"Serilog.Sinks.Console": "[4.0.0-dev-00834, )",
"Serilog.Sinks.Elasticsearch": "[8.4.1, )",
"Serilog.Sinks.File": "[5.0.0, )",
"Serilog.Sinks.Seq": "[5.2.2, )",
"SqlKata": "[2.3.7, )",
"SqlKata.Execution": "[2.3.7, )",
"StackExchange.Redis": "[2.2.88, )",
"System.Interactive.Async": "[5.0.0, )",
"ipnetwork2": "[2.5.381, )"
}
}
}

View File

@ -14,6 +14,7 @@ public class CoreConfig
public string InfluxDb { get; set; }
public string LogDir { get; set; }
public string? ElasticUrl { get; set; }
public string? SeqLogUrl { get; set; }
public LogEventLevel ConsoleLogLevel { get; set; } = LogEventLevel.Debug;
public LogEventLevel ElasticLogLevel { get; set; } = LogEventLevel.Information;

View File

@ -10,6 +10,7 @@ using Serilog;
using Serilog.Events;
using Serilog.Formatting.Compact;
using Serilog.Sinks.Elasticsearch;
using Serilog.Sinks.Seq;
using Serilog.Sinks.SystemConsole.Themes;
using ILogger = Serilog.ILogger;
@ -115,6 +116,15 @@ public class LoggingModule: Module
logCfg.WriteTo.Elasticsearch(elasticConfig);
}
if (config.SeqLogUrl != null)
{
logCfg.WriteTo.Seq(
config.SeqLogUrl,
restrictedToMinimumLevel: LogEventLevel.Verbose
);
}
_fn.Invoke(logCfg);
return Log.Logger = logCfg.CreateLogger();
}

View File

@ -37,14 +37,15 @@
<PackageReference Include="NodaTime.Serialization.JsonNet" Version="3.0.0" />
<PackageReference Include="Npgsql" Version="4.1.5" />
<PackageReference Include="Npgsql.NodaTime" Version="4.1.5" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog" Version="2.12.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
<PackageReference Include="Serilog.Formatting.Compact" Version="1.1.0" />
<PackageReference Include="Serilog.NodaTime" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.4.1-dev-00071" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0-dev-00834" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="8.4.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="5.2.2" />
<PackageReference Include="SqlKata" Version="2.3.7" />
<PackageReference Include="SqlKata.Execution" Version="2.3.7" />
<PackageReference Include="StackExchange.Redis" Version="2.2.88" />

View File

@ -202,9 +202,9 @@
},
"Serilog": {
"type": "Direct",
"requested": "[2.10.0, )",
"resolved": "2.10.0",
"contentHash": "+QX0hmf37a0/OZLxM3wL7V6/ADvC1XihXN4Kq/p6d8lCPfgkRdiuhbWlMaFjR9Av0dy5F0+MBeDmDdRZN/YwQA=="
"requested": "[2.12.0, )",
"resolved": "2.12.0",
"contentHash": "xaiJLIdu6rYMKfQMYUZgTy8YK7SMZjB4Yk50C/u//Z4OsvxkUfSPJy4nknfvwAC34yr13q7kcyh4grbwhSxyZg=="
},
"Serilog.Extensions.Logging": {
"type": "Direct",
@ -274,14 +274,23 @@
},
"Serilog.Sinks.File": {
"type": "Direct",
"requested": "[4.1.0, )",
"resolved": "4.1.0",
"contentHash": "U0b34w+ZikbqWEZ3ui7BdzxY/19zwrdhLtI3o6tfmLdD3oXxg7n2TZJjwCCTlKPgRuYic9CBWfrZevbb70mTaw==",
"requested": "[5.0.0, )",
"resolved": "5.0.0",
"contentHash": "uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==",
"dependencies": {
"Serilog": "2.5.0",
"System.IO.FileSystem": "4.0.1",
"System.Text.Encoding.Extensions": "4.0.11",
"System.Threading.Timer": "4.0.1"
"Serilog": "2.10.0"
}
},
"Serilog.Sinks.Seq": {
"type": "Direct",
"requested": "[5.2.2, )",
"resolved": "5.2.2",
"contentHash": "1Csmo5ua7NKUe0yXUx+zsRefjAniPWcXFhUXxXG8pwo0iMiw2gjn9SOkgYnnxbgWqmlGv236w0N/dHc2v5XwMg==",
"dependencies": {
"Serilog": "2.12.0",
"Serilog.Formatting.Compact": "1.1.0",
"Serilog.Sinks.File": "5.0.0",
"Serilog.Sinks.PeriodicBatching": "3.1.0"
}
},
"SqlKata": {
@ -684,12 +693,10 @@
},
"Serilog.Sinks.PeriodicBatching": {
"type": "Transitive",
"resolved": "2.1.1",
"contentHash": "L1iZtcEzQdEIYCPvhYJYB2RofPg+i1NhHJfS+DpXLyLSMS6OXebqaI1fxWhmJRIjD9D9BuXi23FkZTQDiP7cHw==",
"resolved": "3.1.0",
"contentHash": "NDWR7m3PalVlGEq3rzoktrXikjFMLmpwF0HI4sowo8YDdU+gqPlTHlDQiOGxHfB0sTfjPA9JjA7ctKG9zqjGkw==",
"dependencies": {
"Serilog": "2.0.0",
"System.Collections.Concurrent": "4.0.12",
"System.Threading.Timer": "4.0.1"
"Serilog": "2.0.0"
}
},
"System.AppContext": {