From 47da43e29f7f2af82fca7e9c433d660d5b39518c Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Thu, 24 Sep 2020 17:43:48 -0500 Subject: [PATCH] =?UTF-8?q?fix(logging):=20=F0=9F=90=9B=20try=20fix=20AppI?= =?UTF-8?q?nsights=20logging=20via=20alt=20WriteTo.ApplicationInsights=20o?= =?UTF-8?q?verload?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConfigurationBuilder.cs | 13 +++---------- .../FilterLists.SharedKernel.Logging/HostRunner.cs | 6 +----- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/services/SharedKernel/FilterLists.SharedKernel.Logging/ConfigurationBuilder.cs b/services/SharedKernel/FilterLists.SharedKernel.Logging/ConfigurationBuilder.cs index 386902945..201781f6e 100644 --- a/services/SharedKernel/FilterLists.SharedKernel.Logging/ConfigurationBuilder.cs +++ b/services/SharedKernel/FilterLists.SharedKernel.Logging/ConfigurationBuilder.cs @@ -1,5 +1,4 @@ -using Microsoft.ApplicationInsights; -using Serilog; +using Serilog; using Serilog.Events; namespace FilterLists.SharedKernel.Logging @@ -12,13 +11,7 @@ internal static class ConfigurationBuilder .MinimumLevel.Override("Microsoft", LogEventLevel.Information) .MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning) .Enrich.FromLogContext() - .WriteTo.Console(); - - public static LoggerConfiguration WriteToApplicationInsights( - this LoggerConfiguration loggerConfiguration, - TelemetryClient telemetryClient) - { - return loggerConfiguration.WriteTo.ApplicationInsights(telemetryClient, TelemetryConverter.Traces); - } + .WriteTo.Console() + .WriteTo.ApplicationInsights(TelemetryConverter.Traces); } } diff --git a/services/SharedKernel/FilterLists.SharedKernel.Logging/HostRunner.cs b/services/SharedKernel/FilterLists.SharedKernel.Logging/HostRunner.cs index 39f708e58..552cd028a 100644 --- a/services/SharedKernel/FilterLists.SharedKernel.Logging/HostRunner.cs +++ b/services/SharedKernel/FilterLists.SharedKernel.Logging/HostRunner.cs @@ -1,6 +1,5 @@ using System; using System.Threading.Tasks; -using Microsoft.ApplicationInsights; using Microsoft.Extensions.Hosting; using Serilog; @@ -12,10 +11,7 @@ public static async Task TryRunWithLoggingAsync(this IHost host, Func? run { _ = host ?? throw new ArgumentNullException(nameof(host)); - var telemetryClient = (TelemetryClient)host.Services.GetService(typeof(TelemetryClient)); - Log.Logger = ConfigurationBuilder.BaseLoggerConfiguration - .WriteToApplicationInsights(telemetryClient) - .CreateLogger(); + Log.Logger = ConfigurationBuilder.BaseLoggerConfiguration.CreateLogger(); try {