From a19fdc6c7718bd1248bfc051ab8cc0d05311dcd7 Mon Sep 17 00:00:00 2001 From: Scott Kirkland Date: Fri, 19 Jan 2024 10:17:21 -0800 Subject: [PATCH 1/2] log to stackify if we have a stackify API Key --- Sloth.Api/Logging/LoggingConfiguration.cs | 6 ++++++ Sloth.Api/Sloth.Api.csproj | 1 + Sloth.Web/Logging/LoggingConfiguration.cs | 6 ++++++ Sloth.Web/Sloth.Web.csproj | 1 + 4 files changed, 14 insertions(+) diff --git a/Sloth.Api/Logging/LoggingConfiguration.cs b/Sloth.Api/Logging/LoggingConfiguration.cs index c9e480cc..2ca8c3ef 100644 --- a/Sloth.Api/Logging/LoggingConfiguration.cs +++ b/Sloth.Api/Logging/LoggingConfiguration.cs @@ -57,6 +57,12 @@ public static LoggerConfiguration GetConfiguration() logConfig = logConfig .WriteTo.Console(); + // add in stackify sink if the api key is valid + if (!string.IsNullOrEmpty(loggingSection.GetValue("ApiKey"))) + { + 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.Api/Sloth.Api.csproj b/Sloth.Api/Sloth.Api.csproj index 73292d64..c27219ee 100644 --- a/Sloth.Api/Sloth.Api.csproj +++ b/Sloth.Api/Sloth.Api.csproj @@ -29,6 +29,7 @@ + diff --git a/Sloth.Web/Logging/LoggingConfiguration.cs b/Sloth.Web/Logging/LoggingConfiguration.cs index cbc6ace5..21455c5e 100644 --- a/Sloth.Web/Logging/LoggingConfiguration.cs +++ b/Sloth.Web/Logging/LoggingConfiguration.cs @@ -58,6 +58,12 @@ public static LoggerConfiguration GetConfiguration() logConfig = logConfig .WriteTo.Console(); + // add in stackify sink if the api key is valid + if (!string.IsNullOrEmpty(loggingSection.GetValue("ApiKey"))) + { + 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 b3a53beb..8e373590 100644 --- a/Sloth.Web/Sloth.Web.csproj +++ b/Sloth.Web/Sloth.Web.csproj @@ -35,6 +35,7 @@ + From c149cf559a7d268d33ae114a1e594a9058009cc5 Mon Sep 17 00:00:00 2001 From: Scott Kirkland Date: Fri, 19 Jan 2024 10:26:29 -0800 Subject: [PATCH 2/2] log the jobs in stackify as well --- Sloth.Jobs.Core/Logging/LoggingConfiguration.cs | 6 ++++++ Sloth.Jobs.Core/Sloth.Jobs.Core.csproj | 1 + 2 files changed, 7 insertions(+) diff --git a/Sloth.Jobs.Core/Logging/LoggingConfiguration.cs b/Sloth.Jobs.Core/Logging/LoggingConfiguration.cs index f00dcc6f..6cdb1461 100644 --- a/Sloth.Jobs.Core/Logging/LoggingConfiguration.cs +++ b/Sloth.Jobs.Core/Logging/LoggingConfiguration.cs @@ -63,6 +63,12 @@ public static LoggerConfiguration GetConfiguration() .WriteTo.Console() .WriteToSqlCustom(); + // add in stackify sink if the api key is valid + if (!string.IsNullOrEmpty(loggingSection.GetValue("ApiKey"))) + { + 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.Jobs.Core/Sloth.Jobs.Core.csproj b/Sloth.Jobs.Core/Sloth.Jobs.Core.csproj index 94dd246e..b1fcaec6 100644 --- a/Sloth.Jobs.Core/Sloth.Jobs.Core.csproj +++ b/Sloth.Jobs.Core/Sloth.Jobs.Core.csproj @@ -18,6 +18,7 @@ +