From cd343a7a727c58faa6dc71adb10aa31756ca2867 Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Fri, 25 Sep 2020 07:26:37 -0500 Subject: [PATCH] =?UTF-8?q?Revert=20"fix(logging):=20=F0=9F=90=9B=20try=20?= =?UTF-8?q?alt=20AppInsights=20IKey=20init"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit cd9cdcd53870f5e3bd39cb982809a5ffcd8e8c85. --- .../FilterLists.SharedKernel.Logging/HostRunner.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/services/SharedKernel/FilterLists.SharedKernel.Logging/HostRunner.cs b/services/SharedKernel/FilterLists.SharedKernel.Logging/HostRunner.cs index 197c968e6..7d467b99e 100644 --- a/services/SharedKernel/FilterLists.SharedKernel.Logging/HostRunner.cs +++ b/services/SharedKernel/FilterLists.SharedKernel.Logging/HostRunner.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; -using Microsoft.Extensions.Configuration; +using Microsoft.ApplicationInsights; +using Microsoft.ApplicationInsights.Extensibility; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Serilog; @@ -17,13 +18,16 @@ public static async Task TryRunWithLoggingAsync(this IHost host, Func? run .WriteTo.Conditional( _ => host.Services.GetService().IsProduction(), c => c.ApplicationInsights( - ((IConfiguration)host.Services.GetService(typeof(IConfiguration)))[ - "ApplicationInsights:InstrumentationKey"], + host.Services.GetRequiredService(), TelemetryConverter.Traces)) .CreateLogger(); try { + // TODO: rm, for debugging + var client = host.Services.GetService(); + Log.Warning("Application Insights Instrumentation Key: {InstrumentationKey}", client.InstrumentationKey); + if (runPreHostAsync != null) { Log.Information("Initializing pre-host");