From 80ba723b7d28bc8729b93890b0fb5a6812c9a72a Mon Sep 17 00:00:00 2001 From: ysmoradi Date: Sun, 7 Apr 2024 18:27:29 +0000 Subject: [PATCH] Fix boilerplate's app insight issue for server --- .../src/Boilerplate.Server/Program.Services.cs | 10 +++++----- .../appsettings.Development.json | 7 +++++++ .../Client/Boilerplate.Client.Core/appsettings.json | 9 +++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Boilerplate.Server/Program.Services.cs b/src/Templates/Boilerplate/Bit.Boilerplate/src/Boilerplate.Server/Program.Services.cs index dc773d3b02..34df0d29c1 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Boilerplate.Server/Program.Services.cs +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Boilerplate.Server/Program.Services.cs @@ -51,6 +51,11 @@ private static void ConfigureServices(this WebApplicationBuilder builder) .Configure(opt => opt.Level = CompressionLevel.Fastest) .Configure(opt => opt.Level = CompressionLevel.Fastest); + //#if (appInsights == true) + builder.Logging.AddApplicationInsights(); + services.AddApplicationInsightsTelemetry(configuration); + //#endif + //#if (api == true) var appSettings = configuration.GetSection(nameof(AppSettings)).Get()!; @@ -139,11 +144,6 @@ private static void ConfigureServices(this WebApplicationBuilder builder) //#endif AddBlazor(builder); - - //#if (appInsights == true) - builder.Logging.AddApplicationInsights(); - services.AddApplicationInsightsTelemetry(configuration); - //#endif } private static void AddBlazor(WebApplicationBuilder builder) diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/appsettings.Development.json b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/appsettings.Development.json index de105e558a..edb7165eee 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/appsettings.Development.json +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/appsettings.Development.json @@ -2,6 +2,13 @@ "Logging": { "LogLevel": { "Default": "Information" + }, + //#if (appInsights == true) + "ApplicationInsights": { + "LogLevel": { + "Default": "Information" + } } + //#endif } } \ No newline at end of file diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/appsettings.json b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/appsettings.json index c745ac16ec..46af1953bf 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/appsettings.json +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/appsettings.json @@ -4,7 +4,16 @@ "Default": "Warning", "Boilerplate.Client.Core.Components.AuthenticationStateLogger": "Information", "Microsoft.EntityFrameworkCore.Database.Command": "Information" + }, + //#if (appInsights == true) + "ApplicationInsights": { + "LogLevel": { + "Default": "Warning", + "Boilerplate.Client.Core.Components.AuthenticationStateLogger": "Information", + "Microsoft.EntityFrameworkCore.Database.Command": "Information" + } } + //#endif }, "ApiServerAddress": "http://localhost:5030/", // You can also use relative urls such as / for Blazor Server and WebAssembly "WindowsUpdateSettings": {