From fa0b1a7a6b0e2d216d54e545167607a2f0c9cd25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Tom=C3=A1s?= Date: Thu, 13 Dec 2018 12:13:59 +0100 Subject: [PATCH] Added serilog --- src/ApiGateways/ApiGw-Base/OcelotApiGw.csproj | 2 ++ src/ApiGateways/ApiGw-Base/Program.cs | 10 +++++++++- .../aggregator/Mobile.Shopping.HttpAggregator.csproj | 2 ++ .../Mobile.Bff.Shopping/aggregator/Program.cs | 8 ++++++++ .../Web.Bff.Shopping/aggregator/Program.cs | 8 ++++++++ .../aggregator/Web.Shopping.HttpAggregator.csproj | 2 ++ src/Services/Basket/Basket.API/Basket.API.csproj | 2 ++ src/Services/Basket/Basket.API/Program.cs | 8 ++++++++ src/Services/Catalog/Catalog.API/Catalog.API.csproj | 2 ++ src/Services/Catalog/Catalog.API/Program.cs | 10 +++++++++- .../Identity/Identity.API/Identity.API.csproj | 2 ++ src/Services/Identity/Identity.API/Program.cs | 8 ++++++++ .../Location/Locations.API/Locations.API.csproj | 2 ++ src/Services/Location/Locations.API/Program.cs | 8 ++++++++ .../Marketing/Marketing.API/Marketing.API.csproj | 2 ++ src/Services/Marketing/Marketing.API/Program.cs | 8 ++++++++ .../Ordering/Ordering.API/Ordering.API.csproj | 2 ++ src/Services/Ordering/Ordering.API/Program.cs | 8 ++++++++ .../Ordering.BackgroundTasks.csproj | 2 ++ .../Ordering/Ordering.BackgroundTasks/Program.cs | 11 ++++++++++- .../Ordering.SignalrHub/Ordering.SignalrHub.csproj | 2 ++ src/Services/Ordering/Ordering.SignalrHub/Program.cs | 8 ++++++++ src/Services/Payment/Payment.API/Payment.API.csproj | 2 ++ src/Services/Payment/Payment.API/Program.cs | 8 ++++++++ src/Web/WebMVC/Program.cs | 8 ++++++++ src/Web/WebMVC/WebMVC.csproj | 2 ++ src/Web/WebSPA/Program.cs | 10 +++++++++- src/Web/WebSPA/WebSPA.csproj | 2 ++ src/Web/WebStatus/Program.cs | 8 ++++++++ src/Web/WebStatus/WebStatus.csproj | 2 ++ 30 files changed, 155 insertions(+), 4 deletions(-) diff --git a/src/ApiGateways/ApiGw-Base/OcelotApiGw.csproj b/src/ApiGateways/ApiGw-Base/OcelotApiGw.csproj index 821755d9d..239f3ee49 100644 --- a/src/ApiGateways/ApiGw-Base/OcelotApiGw.csproj +++ b/src/ApiGateways/ApiGw-Base/OcelotApiGw.csproj @@ -11,5 +11,7 @@ + + diff --git a/src/ApiGateways/ApiGw-Base/Program.cs b/src/ApiGateways/ApiGw-Base/Program.cs index effd5684e..c8f8d7993 100644 --- a/src/ApiGateways/ApiGw-Base/Program.cs +++ b/src/ApiGateways/ApiGw-Base/Program.cs @@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using Microsoft.Extensions.DependencyInjection; +using Serilog; namespace OcelotApiGw { @@ -23,7 +24,14 @@ namespace OcelotApiGw IWebHostBuilder builder = WebHost.CreateDefaultBuilder(args); builder.ConfigureServices(s => s.AddSingleton(builder)) .ConfigureAppConfiguration(ic => ic.AddJsonFile(Path.Combine("configuration", "configuration.json"))) - .UseStartup(); + .UseStartup() + .UseSerilog((builderContext, config) => + { + config + .MinimumLevel.Information() + .Enrich.FromLogContext() + .WriteTo.Console(); + }); IWebHost host = builder.Build(); return host; } diff --git a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Mobile.Shopping.HttpAggregator.csproj b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Mobile.Shopping.HttpAggregator.csproj index d13a8a159..d0c0a6c94 100644 --- a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Mobile.Shopping.HttpAggregator.csproj +++ b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Mobile.Shopping.HttpAggregator.csproj @@ -13,6 +13,8 @@ + + diff --git a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Program.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Program.cs index 0c88fcd7d..fc21a70a4 100644 --- a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Program.cs +++ b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Program.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; +using Serilog; namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator { @@ -31,6 +32,13 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator }); }) .UseStartup() + .UseSerilog((builderContext, config) => + { + config + .MinimumLevel.Information() + .Enrich.FromLogContext() + .WriteTo.Console(); + }) .Build(); } } diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs index c865a8b3b..4bbac21e6 100644 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; +using Serilog; namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator { @@ -31,6 +32,13 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator }); }) .UseStartup() + .UseSerilog((builderContext, config) => + { + config + .MinimumLevel.Information() + .Enrich.FromLogContext() + .WriteTo.Console(); + }) .Build(); } } diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/Web.Shopping.HttpAggregator.csproj b/src/ApiGateways/Web.Bff.Shopping/aggregator/Web.Shopping.HttpAggregator.csproj index 00695556b..14c09f6fa 100644 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/Web.Shopping.HttpAggregator.csproj +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/Web.Shopping.HttpAggregator.csproj @@ -13,6 +13,8 @@ + + diff --git a/src/Services/Basket/Basket.API/Basket.API.csproj b/src/Services/Basket/Basket.API/Basket.API.csproj index 3ae587781..8ad45820b 100644 --- a/src/Services/Basket/Basket.API/Basket.API.csproj +++ b/src/Services/Basket/Basket.API/Basket.API.csproj @@ -21,6 +21,8 @@ + + diff --git a/src/Services/Basket/Basket.API/Program.cs b/src/Services/Basket/Basket.API/Program.cs index 303a4625d..0a73ba83c 100644 --- a/src/Services/Basket/Basket.API/Program.cs +++ b/src/Services/Basket/Basket.API/Program.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; +using Serilog; using System; using System.IO; @@ -49,6 +50,13 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API builder.AddConsole(); builder.AddDebug(); }) + .UseSerilog((builderContext, config) => + { + config + .MinimumLevel.Information() + .Enrich.FromLogContext() + .WriteTo.Console(); + }) .UseApplicationInsights() .Build(); } diff --git a/src/Services/Catalog/Catalog.API/Catalog.API.csproj b/src/Services/Catalog/Catalog.API/Catalog.API.csproj index 047a0ef65..3854fb671 100644 --- a/src/Services/Catalog/Catalog.API/Catalog.API.csproj +++ b/src/Services/Catalog/Catalog.API/Catalog.API.csproj @@ -42,6 +42,8 @@ + + diff --git a/src/Services/Catalog/Catalog.API/Program.cs b/src/Services/Catalog/Catalog.API/Program.cs index 8f3910c84..916618d72 100644 --- a/src/Services/Catalog/Catalog.API/Program.cs +++ b/src/Services/Catalog/Catalog.API/Program.cs @@ -6,6 +6,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using Serilog; using System; using System.IO; namespace Microsoft.eShopOnContainers.Services.Catalog.API @@ -60,7 +61,14 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); builder.AddConsole(); builder.AddDebug(); - }) + }) + .UseSerilog((builderContext, config) => + { + config + .MinimumLevel.Information() + .Enrich.FromLogContext() + .WriteTo.Console(); + }) .Build(); } } \ No newline at end of file diff --git a/src/Services/Identity/Identity.API/Identity.API.csproj b/src/Services/Identity/Identity.API/Identity.API.csproj index a7d93aa2a..205db4360 100644 --- a/src/Services/Identity/Identity.API/Identity.API.csproj +++ b/src/Services/Identity/Identity.API/Identity.API.csproj @@ -24,6 +24,8 @@ + + diff --git a/src/Services/Identity/Identity.API/Program.cs b/src/Services/Identity/Identity.API/Program.cs index 6b8353062..9af0397b5 100644 --- a/src/Services/Identity/Identity.API/Program.cs +++ b/src/Services/Identity/Identity.API/Program.cs @@ -6,6 +6,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using Serilog; using System; using System.IO; @@ -69,6 +70,13 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API builder.AddDebug(); }) .UseApplicationInsights() + .UseSerilog((builderContext, config) => + { + config + .MinimumLevel.Information() + .Enrich.FromLogContext() + .WriteTo.Console(); + }) .Build(); } } diff --git a/src/Services/Location/Locations.API/Locations.API.csproj b/src/Services/Location/Locations.API/Locations.API.csproj index 31b7c3930..b89919e75 100644 --- a/src/Services/Location/Locations.API/Locations.API.csproj +++ b/src/Services/Location/Locations.API/Locations.API.csproj @@ -18,6 +18,8 @@ + + diff --git a/src/Services/Location/Locations.API/Program.cs b/src/Services/Location/Locations.API/Program.cs index aedc1bed5..53d4b9400 100644 --- a/src/Services/Location/Locations.API/Program.cs +++ b/src/Services/Location/Locations.API/Program.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; +using Serilog; using System; using System.IO; @@ -45,6 +46,13 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API builder.AddDebug(); }) .UseApplicationInsights() + .UseSerilog((builderContext, config) => + { + config + .MinimumLevel.Information() + .Enrich.FromLogContext() + .WriteTo.Console(); + }) .Build(); } } diff --git a/src/Services/Marketing/Marketing.API/Marketing.API.csproj b/src/Services/Marketing/Marketing.API/Marketing.API.csproj index e96124d80..2dee86bc8 100644 --- a/src/Services/Marketing/Marketing.API/Marketing.API.csproj +++ b/src/Services/Marketing/Marketing.API/Marketing.API.csproj @@ -32,6 +32,8 @@ + + diff --git a/src/Services/Marketing/Marketing.API/Program.cs b/src/Services/Marketing/Marketing.API/Program.cs index 06c5b72ca..25f832646 100644 --- a/src/Services/Marketing/Marketing.API/Program.cs +++ b/src/Services/Marketing/Marketing.API/Program.cs @@ -6,6 +6,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; + using Serilog; using System; using System.IO; @@ -57,6 +58,13 @@ builder.AddDebug(); }) .UseApplicationInsights() + .UseSerilog((builderContext, config) => + { + config + .MinimumLevel.Information() + .Enrich.FromLogContext() + .WriteTo.Console(); + }) .Build(); } } diff --git a/src/Services/Ordering/Ordering.API/Ordering.API.csproj b/src/Services/Ordering/Ordering.API/Ordering.API.csproj index 71bf02c6b..61ac0ea7f 100644 --- a/src/Services/Ordering/Ordering.API/Ordering.API.csproj +++ b/src/Services/Ordering/Ordering.API/Ordering.API.csproj @@ -41,6 +41,8 @@ + + diff --git a/src/Services/Ordering/Ordering.API/Program.cs b/src/Services/Ordering/Ordering.API/Program.cs index 92ef6ba86..ad91e06c2 100644 --- a/src/Services/Ordering/Ordering.API/Program.cs +++ b/src/Services/Ordering/Ordering.API/Program.cs @@ -7,6 +7,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using Serilog; using System; using System.IO; @@ -61,6 +62,13 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API builder.AddDebug(); }) .UseApplicationInsights() + .UseSerilog((builderContext, config) => + { + config + .MinimumLevel.Information() + .Enrich.FromLogContext() + .WriteTo.Console(); + }) .Build(); } } diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj b/src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj index 5ca8b4b3b..86a9ec80f 100644 --- a/src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj +++ b/src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj @@ -17,6 +17,8 @@ + + diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Program.cs b/src/Services/Ordering/Ordering.BackgroundTasks/Program.cs index 23d0a5e42..4f096a265 100644 --- a/src/Services/Ordering/Ordering.BackgroundTasks/Program.cs +++ b/src/Services/Ordering/Ordering.BackgroundTasks/Program.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Logging; +using Serilog; namespace Ordering.BackgroundTasks { @@ -20,6 +21,14 @@ namespace Ordering.BackgroundTasks builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); builder.AddDebug(); builder.AddConsole(); - }).Build(); + }) + .UseSerilog((builderContext, config) => + { + config + .MinimumLevel.Information() + .Enrich.FromLogContext() + .WriteTo.Console(); + }) + .Build(); } } diff --git a/src/Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj b/src/Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj index fad53bbcf..290338eb1 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj +++ b/src/Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj @@ -20,6 +20,8 @@ + + diff --git a/src/Services/Ordering/Ordering.SignalrHub/Program.cs b/src/Services/Ordering/Ordering.SignalrHub/Program.cs index 6598e5504..e8550dcc8 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/Program.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/Program.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; +using Serilog; namespace Ordering.SignalrHub { @@ -20,6 +21,13 @@ namespace Ordering.SignalrHub public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup() + .UseSerilog((builderContext, config) => + { + config + .MinimumLevel.Information() + .Enrich.FromLogContext() + .WriteTo.Console(); + }) .Build(); } } diff --git a/src/Services/Payment/Payment.API/Payment.API.csproj b/src/Services/Payment/Payment.API/Payment.API.csproj index 061e5f237..fe910b077 100644 --- a/src/Services/Payment/Payment.API/Payment.API.csproj +++ b/src/Services/Payment/Payment.API/Payment.API.csproj @@ -14,6 +14,8 @@ + + diff --git a/src/Services/Payment/Payment.API/Program.cs b/src/Services/Payment/Payment.API/Program.cs index aff7bf359..2138b48b8 100644 --- a/src/Services/Payment/Payment.API/Program.cs +++ b/src/Services/Payment/Payment.API/Program.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; +using Serilog; using System.IO; namespace Payment.API @@ -30,6 +31,13 @@ namespace Payment.API builder.AddDebug(); }) .UseApplicationInsights() + .UseSerilog((builderContext, config) => + { + config + .MinimumLevel.Information() + .Enrich.FromLogContext() + .WriteTo.Console(); + }) .Build(); } } diff --git a/src/Web/WebMVC/Program.cs b/src/Web/WebMVC/Program.cs index 07332a02a..7180a0d6c 100644 --- a/src/Web/WebMVC/Program.cs +++ b/src/Web/WebMVC/Program.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; +using Serilog; using System.IO; namespace Microsoft.eShopOnContainers.WebMVC @@ -29,6 +30,13 @@ namespace Microsoft.eShopOnContainers.WebMVC builder.AddDebug(); }) .UseApplicationInsights() + .UseSerilog((builderContext, config) => + { + config + .MinimumLevel.Information() + .Enrich.FromLogContext() + .WriteTo.Console(); + }) .Build(); } } diff --git a/src/Web/WebMVC/WebMVC.csproj b/src/Web/WebMVC/WebMVC.csproj index 552b3842a..1b158bc7e 100644 --- a/src/Web/WebMVC/WebMVC.csproj +++ b/src/Web/WebMVC/WebMVC.csproj @@ -31,6 +31,8 @@ + + diff --git a/src/Web/WebSPA/Program.cs b/src/Web/WebSPA/Program.cs index c1a7da269..705e39f4f 100644 --- a/src/Web/WebSPA/Program.cs +++ b/src/Web/WebSPA/Program.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Hosting; using System.IO; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Configuration; +using Serilog; namespace eShopConContainers.WebSPA { @@ -28,7 +29,14 @@ namespace eShopConContainers.WebSPA builder.AddConsole(); builder.AddDebug(); }) - .UseApplicationInsights() + .UseApplicationInsights() + .UseSerilog((builderContext, config) => + { + config + .MinimumLevel.Information() + .Enrich.FromLogContext() + .WriteTo.Console(); + }) .Build(); } } diff --git a/src/Web/WebSPA/WebSPA.csproj b/src/Web/WebSPA/WebSPA.csproj index c833124ac..bc4b73851 100644 --- a/src/Web/WebSPA/WebSPA.csproj +++ b/src/Web/WebSPA/WebSPA.csproj @@ -93,6 +93,8 @@ + + diff --git a/src/Web/WebStatus/Program.cs b/src/Web/WebStatus/Program.cs index adab0e6b3..ce1048c68 100644 --- a/src/Web/WebStatus/Program.cs +++ b/src/Web/WebStatus/Program.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; +using Serilog; using System.IO; namespace WebStatus @@ -28,6 +29,13 @@ namespace WebStatus builder.AddDebug(); }) .UseApplicationInsights() + .UseSerilog((builderContext, config) => + { + config + .MinimumLevel.Information() + .Enrich.FromLogContext() + .WriteTo.Console(); + }) .Build(); } } diff --git a/src/Web/WebStatus/WebStatus.csproj b/src/Web/WebStatus/WebStatus.csproj index 4755ec744..1e019dd8f 100644 --- a/src/Web/WebStatus/WebStatus.csproj +++ b/src/Web/WebStatus/WebStatus.csproj @@ -12,6 +12,8 @@ + +