diff --git a/services/Archival/FilterLists.Archival.Api/Program.cs b/services/Archival/FilterLists.Archival.Api/Program.cs index c65f57179c..1dff78331d 100644 --- a/services/Archival/FilterLists.Archival.Api/Program.cs +++ b/services/Archival/FilterLists.Archival.Api/Program.cs @@ -1,4 +1,4 @@ -using System.Threading.Tasks; +using System.Threading.Tasks; using FilterLists.Archival.Application; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Hosting; @@ -17,8 +17,8 @@ public static async Task Main(string[] args) public static IHostBuilder CreateHostBuilder(string[] args) { return Host.CreateDefaultBuilder(args) - .UseApplication() - .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup()); + .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup()) + .UseApplication(); } } } diff --git a/services/Directory/FilterLists.Directory.Api/Program.cs b/services/Directory/FilterLists.Directory.Api/Program.cs index f5528dafd2..71dfea2892 100644 --- a/services/Directory/FilterLists.Directory.Api/Program.cs +++ b/services/Directory/FilterLists.Directory.Api/Program.cs @@ -1,9 +1,9 @@ -using System.Threading.Tasks; +using System.Threading.Tasks; using FilterLists.Directory.Application; using FilterLists.Directory.Infrastructure.Persistence; +using FilterLists.SharedKernel.Logging; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Hosting; -using static FilterLists.SharedKernel.Logging.HostRunner; namespace FilterLists.Directory.Api { @@ -18,8 +18,8 @@ public static async Task Main(string[] args) public static IHostBuilder CreateHostBuilder(string[] args) { return Host.CreateDefaultBuilder(args) - .UseApplication() - .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup()); + .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup()) + .UseApplication(); } } } diff --git a/services/SharedKernel/FilterLists.SharedKernel.Logging/HostRunner.cs b/services/SharedKernel/FilterLists.SharedKernel.Logging/HostRunner.cs index a0559a11ab..2532135e94 100644 --- a/services/SharedKernel/FilterLists.SharedKernel.Logging/HostRunner.cs +++ b/services/SharedKernel/FilterLists.SharedKernel.Logging/HostRunner.cs @@ -1,6 +1,6 @@ using System; using System.Threading.Tasks; -using Microsoft.ApplicationInsights.Extensibility; +using Microsoft.ApplicationInsights; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Serilog; @@ -13,14 +13,11 @@ 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 .WriteTo.Conditional( _ => host.Services.GetService().IsProduction(), - c => c.ApplicationInsights( -#pragma warning disable CS0618 - TelemetryConfiguration.Active, -#pragma warning restore CS0618 - TelemetryConverter.Traces)) + c => c.ApplicationInsights(telemetryClient, TelemetryConverter.Traces)) .CreateLogger(); try