From da0806da591e60da1d5dd749c6a669bb5172da69 Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Sat, 26 Sep 2020 09:02:19 -0500 Subject: [PATCH] =?UTF-8?q?refactor(logging):=20=E2=99=BB=20rm=20Hosting.A?= =?UTF-8?q?bstractions=20dep?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConfigurationExtensions.cs | 14 +++++++------- .../FilterLists.SharedKernel.Logging.csproj | 5 ++--- .../FilterLists.SharedKernel.Logging/HostRunner.cs | 8 +++----- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/services/SharedKernel/FilterLists.SharedKernel.Logging/ConfigurationExtensions.cs b/services/SharedKernel/FilterLists.SharedKernel.Logging/ConfigurationExtensions.cs index b39ff1ee4..76ab48a6e 100644 --- a/services/SharedKernel/FilterLists.SharedKernel.Logging/ConfigurationExtensions.cs +++ b/services/SharedKernel/FilterLists.SharedKernel.Logging/ConfigurationExtensions.cs @@ -21,13 +21,13 @@ public static void AddSharedKernelLogging(this IServiceCollection services, ICon { _ = configuration ?? throw new ArgumentNullException(nameof(configuration)); - //using var serverTelemetryChannel = new ServerTelemetryChannel - //{ - // StorageFolder = configuration.GetSection(ApplicationInsightsOptions.Key) - // .Get() - // .ServerTelemetryChannelStoragePath - //}; - //services.AddSingleton(typeof(ITelemetryChannel), serverTelemetryChannel); + using var serverTelemetryChannel = new ServerTelemetryChannel + { + StorageFolder = configuration.GetSection(ApplicationInsightsOptions.Key) + .Get() + .ServerTelemetryChannelStoragePath + }; + services.AddSingleton(typeof(ITelemetryChannel), serverTelemetryChannel); services.AddApplicationInsightsTelemetry(); } diff --git a/services/SharedKernel/FilterLists.SharedKernel.Logging/FilterLists.SharedKernel.Logging.csproj b/services/SharedKernel/FilterLists.SharedKernel.Logging/FilterLists.SharedKernel.Logging.csproj index a1480e1da..a101d7a2d 100644 --- a/services/SharedKernel/FilterLists.SharedKernel.Logging/FilterLists.SharedKernel.Logging.csproj +++ b/services/SharedKernel/FilterLists.SharedKernel.Logging/FilterLists.SharedKernel.Logging.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 @@ -17,12 +17,11 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/services/SharedKernel/FilterLists.SharedKernel.Logging/HostRunner.cs b/services/SharedKernel/FilterLists.SharedKernel.Logging/HostRunner.cs index d5f30cecf..4d3818236 100644 --- a/services/SharedKernel/FilterLists.SharedKernel.Logging/HostRunner.cs +++ b/services/SharedKernel/FilterLists.SharedKernel.Logging/HostRunner.cs @@ -14,11 +14,9 @@ public static async Task TryRunWithLoggingAsync(this IHost host, Func? run _ = host ?? throw new ArgumentNullException(nameof(host)); Log.Logger = ConfigurationBuilder.BaseLoggerConfiguration - .WriteTo.Conditional( - _ => host.Services.GetService().IsProduction(), - c => c.ApplicationInsights( - host.Services.GetRequiredService(), - TelemetryConverter.Traces)) + .WriteTo.ApplicationInsights( + host.Services.GetRequiredService(), + TelemetryConverter.Traces) .CreateLogger(); try