Skip to content

Commit

Permalink
need to call configureStackifyLogging
Browse files Browse the repository at this point in the history
otherwise app settings don't get loaded in
  • Loading branch information
srkirkland committed Jan 19, 2024
1 parent c0b7f03 commit 0f75b38
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions Sloth.Api/Sloth.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="8.4.1" />
<PackageReference Include="Serilog.Sinks.MSSqlServer" Version="5.7.1" />
<PackageReference Include="Serilog.Sinks.Stackify" Version="2.0.2" />
<PackageReference Include="StackifyLib" Version="2.2.13" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.1" />
</ItemGroup>

Expand Down
1 change: 1 addition & 0 deletions Sloth.Jobs.Core/Sloth.Jobs.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="8.4.1" />
<PackageReference Include="Serilog.Sinks.MSSqlServer" Version="5.7.1" />
<PackageReference Include="Serilog.Sinks.Stackify" Version="2.0.2" />
<PackageReference Include="StackifyLib" Version="2.2.13" />
</ItemGroup>

</Project>
10 changes: 7 additions & 3 deletions Sloth.Web/Logging/LoggingConfiguration.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -61,9 +60,14 @@ public static LoggerConfiguration GetConfiguration()
// add in stackify sink if the api key is valid
if (!string.IsNullOrEmpty(loggingSection.GetValue<string>("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<string>("ElasticUrl"), UriKind.Absolute, out var elasticUri))
{
Expand Down
2 changes: 2 additions & 0 deletions Sloth.Web/Sloth.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
<PackageReference Include="Serilog.Sinks.Stackify" Version="2.0.2" />

<PackageReference Include="SSH.NET" Version="2020.0.2" />

<PackageReference Include="StackifyLib" Version="2.2.13" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 0f75b38

Please sign in to comment.