From 1fa6242c1c1a2ad46b100a587fef6108ae468182 Mon Sep 17 00:00:00 2001 From: Cesar De la Torre Llorente Date: Mon, 21 May 2018 18:11:27 -0700 Subject: [PATCH] Added opt-in HttpClientLogging config --- src/Web/WebMVC/Startup.cs | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/Web/WebMVC/Startup.cs b/src/Web/WebMVC/Startup.cs index 655ab1e68..3df96da2c 100644 --- a/src/Web/WebMVC/Startup.cs +++ b/src/Web/WebMVC/Startup.cs @@ -36,10 +36,11 @@ namespace Microsoft.eShopOnContainers.WebMVC public void ConfigureServices(IServiceCollection services) { services.AddAppInsight(Configuration) - .AddHealthChecks(Configuration) - .AddCustomMvc(Configuration) - .AddHttpClientServices(Configuration) - .AddCustomAuthentication(Configuration); + .AddHealthChecks(Configuration) + .AddCustomMvc(Configuration) + .AddHttpClientServices(Configuration) + //.AddHttpClientLogging(Configuration) //Opt-in HttpClientLogging config + .AddCustomAuthentication(Configuration); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -216,6 +217,23 @@ namespace Microsoft.eShopOnContainers.WebMVC return services; } + + public static IServiceCollection AddHttpClientLogging(this IServiceCollection services, IConfiguration configuration) + { + services.AddLogging(b => + { + b.AddFilter((category, level) => true); // Spam the world with logs. + + // Add console logger so we can see all the logging produced by the client by default. + b.AddConsole(c => c.IncludeScopes = true); + + // Add console logger + b.AddDebug(); + }); + + return services; + } + public static IServiceCollection AddCustomAuthentication(this IServiceCollection services, IConfiguration configuration) { var useLoadTest = configuration.GetValue("UseLoadTest");