From 0f75b385146ae91d40e9683d30f8d7c925aa8a2c Mon Sep 17 00:00:00 2001 From: Scott Kirkland Date: Fri, 19 Jan 2024 11:47:14 -0800 Subject: [PATCH 1/2] need to call configureStackifyLogging otherwise app settings don't get loaded in --- Sloth.Api/Sloth.Api.csproj | 1 + Sloth.Jobs.Core/Sloth.Jobs.Core.csproj | 1 + Sloth.Web/Logging/LoggingConfiguration.cs | 10 +++++++--- Sloth.Web/Sloth.Web.csproj | 2 ++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Sloth.Api/Sloth.Api.csproj b/Sloth.Api/Sloth.Api.csproj index c27219ee..48227942 100644 --- a/Sloth.Api/Sloth.Api.csproj +++ b/Sloth.Api/Sloth.Api.csproj @@ -30,6 +30,7 @@ + diff --git a/Sloth.Jobs.Core/Sloth.Jobs.Core.csproj b/Sloth.Jobs.Core/Sloth.Jobs.Core.csproj index b1fcaec6..11e4ac05 100644 --- a/Sloth.Jobs.Core/Sloth.Jobs.Core.csproj +++ b/Sloth.Jobs.Core/Sloth.Jobs.Core.csproj @@ -19,6 +19,7 @@ + diff --git a/Sloth.Web/Logging/LoggingConfiguration.cs b/Sloth.Web/Logging/LoggingConfiguration.cs index 21455c5e..fa67440f 100644 --- a/Sloth.Web/Logging/LoggingConfiguration.cs +++ b/Sloth.Web/Logging/LoggingConfiguration.cs @@ -1,14 +1,13 @@ using System; using System.Collections.Generic; using System.Data; -using System.Diagnostics; using Microsoft.Extensions.Configuration; using Serilog; using Serilog.Events; using Serilog.Exceptions; using Serilog.Sinks.Elasticsearch; using Serilog.Sinks.MSSqlServer; -using Serilog.Sinks.MSSqlServer.Sinks.MSSqlServer.Options; +using StackifyLib; namespace Sloth.Web.Logging { @@ -61,9 +60,14 @@ public static LoggerConfiguration GetConfiguration() // add in stackify sink if the api key is valid if (!string.IsNullOrEmpty(loggingSection.GetValue("ApiKey"))) { + if (!_loggingSetup) + { + _configuration.ConfigureStackifyLogging(); // applies stackify settings + } + logConfig = logConfig.WriteTo.Stackify(); } - + // add in elastic search sink if the uri is valid if (Uri.TryCreate(loggingSection.GetValue("ElasticUrl"), UriKind.Absolute, out var elasticUri)) { diff --git a/Sloth.Web/Sloth.Web.csproj b/Sloth.Web/Sloth.Web.csproj index 8e373590..4841b318 100644 --- a/Sloth.Web/Sloth.Web.csproj +++ b/Sloth.Web/Sloth.Web.csproj @@ -38,6 +38,8 @@ + + From 3f0de83eaeaff0782c4460d4b70c7b903699b406 Mon Sep 17 00:00:00 2001 From: Scott Kirkland Date: Fri, 19 Jan 2024 11:47:55 -0800 Subject: [PATCH 2/2] add in to api and jobs too --- Sloth.Api/Logging/LoggingConfiguration.cs | 6 ++++++ Sloth.Jobs.Core/Logging/LoggingConfiguration.cs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/Sloth.Api/Logging/LoggingConfiguration.cs b/Sloth.Api/Logging/LoggingConfiguration.cs index 2ca8c3ef..234d7bac 100644 --- a/Sloth.Api/Logging/LoggingConfiguration.cs +++ b/Sloth.Api/Logging/LoggingConfiguration.cs @@ -7,6 +7,7 @@ using Serilog.Exceptions; using Serilog.Sinks.Elasticsearch; using Serilog.Sinks.MSSqlServer; +using StackifyLib; namespace Sloth.Api.Logging { @@ -60,6 +61,11 @@ public static LoggerConfiguration GetConfiguration() // add in stackify sink if the api key is valid if (!string.IsNullOrEmpty(loggingSection.GetValue("ApiKey"))) { + if (!_loggingSetup) + { + _configuration.ConfigureStackifyLogging(); // applies stackify settings + } + logConfig = logConfig.WriteTo.Stackify(); } diff --git a/Sloth.Jobs.Core/Logging/LoggingConfiguration.cs b/Sloth.Jobs.Core/Logging/LoggingConfiguration.cs index 6cdb1461..92de6c30 100644 --- a/Sloth.Jobs.Core/Logging/LoggingConfiguration.cs +++ b/Sloth.Jobs.Core/Logging/LoggingConfiguration.cs @@ -8,6 +8,7 @@ using Serilog.Sinks.Elasticsearch; using Serilog.Sinks.MSSqlServer; using Serilog.Sinks.MSSqlServer.Sinks.MSSqlServer.Options; +using StackifyLib; namespace Sloth.Jobs.Core.Logging { @@ -66,6 +67,11 @@ public static LoggerConfiguration GetConfiguration() // add in stackify sink if the api key is valid if (!string.IsNullOrEmpty(loggingSection.GetValue("ApiKey"))) { + if (!_loggingSetup) + { + _configuration.ConfigureStackifyLogging(); // applies stackify settings + } + logConfig = logConfig.WriteTo.Stackify(); }