diff --git a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/GlobalUsings.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/GlobalUsings.cs
index 2fbd09b57..6f18651cf 100644
--- a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/GlobalUsings.cs
+++ b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/GlobalUsings.cs
@@ -25,7 +25,6 @@ global using Microsoft.Extensions.Hosting;
global using Microsoft.Extensions.Logging;
global using Microsoft.Extensions.Options;
global using Microsoft.OpenApi.Models;
-global using Serilog;
global using Swashbuckle.AspNetCore.SwaggerGen;
global using System.Collections.Generic;
global using System.IdentityModel.Tokens.Jwt;
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 78b2d6780..a25016890 100644
--- a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Mobile.Shopping.HttpAggregator.csproj
+++ b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Mobile.Shopping.HttpAggregator.csproj
@@ -25,8 +25,6 @@
-
-
diff --git a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Program.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Program.cs
index 92e7e3a37..d6f7ae482 100644
--- a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Program.cs
+++ b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Program.cs
@@ -1,4 +1,4 @@
-await BuildWebHost(args).RunAsync();
+await BuildWebHost(args).RunAsync();
IWebHost BuildWebHost(string[] args) =>
WebHost
.CreateDefaultBuilder(args)
@@ -13,11 +13,4 @@ IWebHost BuildWebHost(string[] args) =>
});
})
.UseStartup()
- .UseSerilog((builderContext, config) =>
- {
- config
- .MinimumLevel.Information()
- .Enrich.FromLogContext()
- .WriteTo.Console();
- })
- .Build();
\ No newline at end of file
+ .Build();
diff --git a/src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationEventHandler.cs b/src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationEventHandler.cs
index 8545dc893..b82ac6a5f 100644
--- a/src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationEventHandler.cs
+++ b/src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationEventHandler.cs
@@ -12,9 +12,10 @@ namespace EventBus.Tests
Handled = false;
}
- public async Task Handle(TestIntegrationEvent @event)
+ public Task Handle(TestIntegrationEvent @event)
{
Handled = true;
+ return Task.CompletedTask;
}
}
}
diff --git a/src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationOtherEventHandler.cs b/src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationOtherEventHandler.cs
index b4ea66bb4..82ea25baa 100644
--- a/src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationOtherEventHandler.cs
+++ b/src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationOtherEventHandler.cs
@@ -12,9 +12,10 @@ namespace EventBus.Tests
Handled = false;
}
- public async Task Handle(TestIntegrationEvent @event)
+ public Task Handle(TestIntegrationEvent @event)
{
Handled = true;
+ return Task.CompletedTask;
}
}
}
diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props
index 6114b6a05..4f8a92814 100644
--- a/src/Directory.Packages.props
+++ b/src/Directory.Packages.props
@@ -83,12 +83,6 @@
-
-
-
-
-
-
diff --git a/src/Services/Basket/Basket.API/GlobalUsings.cs b/src/Services/Basket/Basket.API/GlobalUsings.cs
index bef9dcdae..768af4a41 100644
--- a/src/Services/Basket/Basket.API/GlobalUsings.cs
+++ b/src/Services/Basket/Basket.API/GlobalUsings.cs
@@ -33,6 +33,5 @@ global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Hosting;
global using Microsoft.Extensions.Logging;
-global using Serilog.Context;
global using Services.Common;
global using StackExchange.Redis;
diff --git a/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/OrderStartedIntegrationEventHandler.cs b/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/OrderStartedIntegrationEventHandler.cs
index d5cf14e1b..df18a065c 100644
--- a/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/OrderStartedIntegrationEventHandler.cs
+++ b/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/OrderStartedIntegrationEventHandler.cs
@@ -15,7 +15,7 @@ public class OrderStartedIntegrationEventHandler : IIntegrationEventHandler> { new ("IntegrationEventContext", @event.Id) }))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event);
diff --git a/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs b/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs
index 560c43d2a..cff2faa05 100644
--- a/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs
+++ b/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs
@@ -15,7 +15,7 @@ public class ProductPriceChangedIntegrationEventHandler : IIntegrationEventHandl
public async Task Handle(ProductPriceChangedIntegrationEvent @event)
{
- using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}"))
+ using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) }))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event);
diff --git a/src/Services/Basket/Basket.API/appsettings.Development.json b/src/Services/Basket/Basket.API/appsettings.Development.json
index f4a3b9407..0c8e39c3c 100644
--- a/src/Services/Basket/Basket.API/appsettings.Development.json
+++ b/src/Services/Basket/Basket.API/appsettings.Development.json
@@ -1,14 +1,4 @@
{
- "Serilog": {
- "MinimumLevel": {
- "Default": "Debug",
- "Override": {
- "Microsoft": "Warning",
- "Microsoft.eShopOnContainers": "Debug",
- "System": "Warning"
- }
- }
- },
"IdentityUrlExternal": "http://localhost:5105",
"IdentityUrl": "http://localhost:5105",
"ConnectionString": "127.0.0.1",
diff --git a/src/Services/Catalog/Catalog.API/Catalog.API.csproj b/src/Services/Catalog/Catalog.API/Catalog.API.csproj
index 0d834939a..29573e967 100644
--- a/src/Services/Catalog/Catalog.API/Catalog.API.csproj
+++ b/src/Services/Catalog/Catalog.API/Catalog.API.csproj
@@ -60,12 +60,6 @@
-
-
-
-
-
-
diff --git a/src/Services/Catalog/Catalog.API/GlobalUsings.cs b/src/Services/Catalog/Catalog.API/GlobalUsings.cs
index 812aa9960..fdd190250 100644
--- a/src/Services/Catalog/Catalog.API/GlobalUsings.cs
+++ b/src/Services/Catalog/Catalog.API/GlobalUsings.cs
@@ -44,4 +44,3 @@ global using Microsoft.Extensions.Logging;
global using Microsoft.Extensions.Options;
global using Polly;
global using Polly.Retry;
-global using Serilog.Context;
diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs
index 81c9ff909..fb79b96e9 100644
--- a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs
+++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs
@@ -19,7 +19,7 @@ public class OrderStatusChangedToAwaitingValidationIntegrationEventHandler :
public async Task Handle(OrderStatusChangedToAwaitingValidationIntegrationEvent @event)
{
- using (LogContext.PushProperty("IntegrationEventContext", @event.Id))
+ using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) }))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event);
diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs
index c0f87139a..99b755568 100644
--- a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs
+++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs
@@ -16,7 +16,7 @@ public class OrderStatusChangedToPaidIntegrationEventHandler :
public async Task Handle(OrderStatusChangedToPaidIntegrationEvent @event)
{
- using (LogContext.PushProperty("IntegrationEventContext", @event.Id))
+ using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) }))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event);
diff --git a/src/Services/Catalog/Catalog.API/Properties/launchSettings.json b/src/Services/Catalog/Catalog.API/Properties/launchSettings.json
index 71aab05ab..a85ce1869 100644
--- a/src/Services/Catalog/Catalog.API/Properties/launchSettings.json
+++ b/src/Services/Catalog/Catalog.API/Properties/launchSettings.json
@@ -14,10 +14,8 @@
"launchUrl": "/swagger",
"environmentVariables": {
"ConnectionString": "server=localhost,5433;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word",
- "Serilog:LogstashgUrl": "http://locahost:8080",
"ASPNETCORE_ENVIRONMENT": "Development",
- "EventBusConnection": "localhost",
- "Serilog:SeqServerUrl": "http://locahost:5340"
+ "EventBusConnection": "localhost"
}
},
"Microsoft.eShopOnContainers.Services.Catalog.API": {
diff --git a/src/Services/Catalog/Catalog.API/appsettings.Development.json b/src/Services/Catalog/Catalog.API/appsettings.Development.json
index 1d5574f63..b41dc527c 100644
--- a/src/Services/Catalog/Catalog.API/appsettings.Development.json
+++ b/src/Services/Catalog/Catalog.API/appsettings.Development.json
@@ -1,15 +1,5 @@
{
"ConnectionString": "Server=tcp:127.0.0.1,5433;Initial Catalog=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word",
"PicBaseUrl": "http://localhost:5101/api/v1/catalog/items/[0]/pic/",
- "Serilog": {
- "MinimumLevel": {
- "Default": "Debug",
- "Override": {
- "Microsoft": "Warning",
- "Microsoft.eShopOnContainers": "Debug",
- "System": "Warning"
- }
- }
- },
"EventBusConnection": "localhost"
}
\ No newline at end of file
diff --git a/src/Services/Catalog/Catalog.API/appsettings.json b/src/Services/Catalog/Catalog.API/appsettings.json
index c05acb89b..0141b6a7b 100644
--- a/src/Services/Catalog/Catalog.API/appsettings.json
+++ b/src/Services/Catalog/Catalog.API/appsettings.json
@@ -1,17 +1,5 @@
{
"UseCustomizationData": false,
- "Serilog": {
- "SeqServerUrl": null,
- "LogstashgUrl": null,
- "MinimumLevel": {
- "Default": "Information",
- "Override": {
- "Microsoft": "Warning",
- "Microsoft.eShopOnContainers": "Information",
- "System": "Warning"
- }
- }
- },
"AzureServiceBusEnabled": false,
"AzureStorageEnabled": false,
"ApplicationInsights": {
diff --git a/src/Services/Catalog/Catalog.API/web.config b/src/Services/Catalog/Catalog.API/web.config
index 498dea85d..3bc0d036f 100644
--- a/src/Services/Catalog/Catalog.API/web.config
+++ b/src/Services/Catalog/Catalog.API/web.config
@@ -8,10 +8,8 @@
-
-
diff --git a/src/Services/Identity/Identity.API/appsettings.json b/src/Services/Identity/Identity.API/appsettings.json
index cc37da9fe..955033706 100644
--- a/src/Services/Identity/Identity.API/appsettings.json
+++ b/src/Services/Identity/Identity.API/appsettings.json
@@ -4,17 +4,6 @@
"SpaClient": "http://localhost:5104",
"XamarinCallback": "http://localhost:5105/xamarincallback",
"UseCustomizationData": false,
- "Serilog": {
- "SeqServerUrl": null,
- "LogstashgUrl": null,
- "MinimumLevel": {
- "Default": "Information",
- "Override": {
- "Microsoft.AspNetCore": "Warning",
- "Microsoft.EntityFramework": "Warning"
- }
- }
- },
"ApplicationInsights": {
"InstrumentationKey": ""
},
diff --git a/src/Services/Ordering/Ordering.API/Application/Behaviors/TransactionBehavior.cs b/src/Services/Ordering/Ordering.API/Application/Behaviors/TransactionBehavior.cs
index 6974c3cf9..c27865a1e 100644
--- a/src/Services/Ordering/Ordering.API/Application/Behaviors/TransactionBehavior.cs
+++ b/src/Services/Ordering/Ordering.API/Application/Behaviors/TransactionBehavior.cs
@@ -36,7 +36,7 @@ public class TransactionBehavior : IPipelineBehavior> { new ("TransactionContext", transaction.TransactionId) }))
{
_logger.LogInformation("----- Begin transaction {TransactionId} for {CommandName} ({@Command})", transaction.TransactionId, typeName, request);
diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/GracePeriodConfirmedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/GracePeriodConfirmedIntegrationEventHandler.cs
index a6056041c..82d3a0b3a 100644
--- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/GracePeriodConfirmedIntegrationEventHandler.cs
+++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/GracePeriodConfirmedIntegrationEventHandler.cs
@@ -23,9 +23,9 @@ public class GracePeriodConfirmedIntegrationEventHandler : IIntegrationEventHand
///
public async Task Handle(GracePeriodConfirmedIntegrationEvent @event)
{
- using (LogContext.PushProperty("IntegrationEventContext", @event.Id))
+ using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) }))
{
- _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
+ _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event);
var command = new SetAwaitingValidationOrderStatusCommand(@event.OrderId);
diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentFailedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentFailedIntegrationEventHandler.cs
index 8725408b4..870d63d60 100644
--- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentFailedIntegrationEventHandler.cs
+++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentFailedIntegrationEventHandler.cs
@@ -16,9 +16,9 @@ public class OrderPaymentFailedIntegrationEventHandler :
public async Task Handle(OrderPaymentFailedIntegrationEvent @event)
{
- using (LogContext.PushProperty("IntegrationEventContext", @event.Id))
+ using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) }))
{
- _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
+ _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event);
var command = new CancelOrderCommand(@event.OrderId);
diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentSucceededIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentSucceededIntegrationEventHandler.cs
index c0a69268e..e1e6a9e86 100644
--- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentSucceededIntegrationEventHandler.cs
+++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentSucceededIntegrationEventHandler.cs
@@ -16,9 +16,9 @@ public class OrderPaymentSucceededIntegrationEventHandler :
public async Task Handle(OrderPaymentSucceededIntegrationEvent @event)
{
- using (LogContext.PushProperty("IntegrationEventContext", @event.Id))
+ using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) }))
{
- _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
+ _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event);
var command = new SetPaidOrderStatusCommand(@event.OrderId);
diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockConfirmedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockConfirmedIntegrationEventHandler.cs
index e99b49f5e..68f2ec066 100644
--- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockConfirmedIntegrationEventHandler.cs
+++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockConfirmedIntegrationEventHandler.cs
@@ -16,9 +16,9 @@ public class OrderStockConfirmedIntegrationEventHandler :
public async Task Handle(OrderStockConfirmedIntegrationEvent @event)
{
- using (LogContext.PushProperty("IntegrationEventContext", @event.Id))
+ using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) }))
{
- _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
+ _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event);
var command = new SetStockConfirmedOrderStatusCommand(@event.OrderId);
diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockRejectedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockRejectedIntegrationEventHandler.cs
index 2468e25a6..4fa90ae0d 100644
--- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockRejectedIntegrationEventHandler.cs
+++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockRejectedIntegrationEventHandler.cs
@@ -14,9 +14,9 @@ public class OrderStockRejectedIntegrationEventHandler : IIntegrationEventHandle
public async Task Handle(OrderStockRejectedIntegrationEvent @event)
{
- using (LogContext.PushProperty("IntegrationEventContext", @event.Id))
+ using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) }))
{
- _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
+ _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event);
var orderStockRejectedItems = @event.OrderStockItems
.FindAll(c => !c.HasStock)
diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/UserCheckoutAcceptedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/UserCheckoutAcceptedIntegrationEventHandler.cs
index f1c3cc964..d30ad98b5 100644
--- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/UserCheckoutAcceptedIntegrationEventHandler.cs
+++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/UserCheckoutAcceptedIntegrationEventHandler.cs
@@ -24,15 +24,15 @@ public class UserCheckoutAcceptedIntegrationEventHandler : IIntegrationEventHand
///
public async Task Handle(UserCheckoutAcceptedIntegrationEvent @event)
{
- using (LogContext.PushProperty("IntegrationEventContext", @event.Id))
+ using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) }))
{
- _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
+ _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event);
var result = false;
if (@event.RequestId != Guid.Empty)
{
- using (LogContext.PushProperty("IdentifiedCommandId", @event.RequestId))
+ using (_logger.BeginScope(new List> { new ("IdentifiedCommandId", @event.RequestId) }))
{
var createOrderCommand = new CreateOrderCommand(@event.Basket.Items, @event.UserId, @event.UserName, @event.City, @event.Street,
@event.State, @event.Country, @event.ZipCode,
diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/OrderingIntegrationEventService.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/OrderingIntegrationEventService.cs
index e2545cae5..a38179f5f 100644
--- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/OrderingIntegrationEventService.cs
+++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/OrderingIntegrationEventService.cs
@@ -27,7 +27,7 @@ public class OrderingIntegrationEventService : IOrderingIntegrationEventService
foreach (var logEvt in pendingLogEvents)
{
- _logger.LogInformation("----- Publishing integration event: {IntegrationEventId} from {AppName} - ({@IntegrationEvent})", logEvt.EventId, Program.AppName, logEvt.IntegrationEvent);
+ _logger.LogInformation("----- Publishing integration event: {IntegrationEventId} - ({@IntegrationEvent})", logEvt.EventId, logEvt.IntegrationEvent);
try
{
@@ -37,7 +37,7 @@ public class OrderingIntegrationEventService : IOrderingIntegrationEventService
}
catch (Exception ex)
{
- _logger.LogError(ex, "ERROR publishing integration event: {IntegrationEventId} from {AppName}", logEvt.EventId, Program.AppName);
+ _logger.LogError(ex, "ERROR publishing integration event: {IntegrationEventId}", logEvt.EventId);
await _eventLogService.MarkEventAsFailedAsync(logEvt.EventId);
}
diff --git a/src/Services/Ordering/Ordering.API/Extensions/BasketItemExtensions.cs b/src/Services/Ordering/Ordering.API/Extensions/BasketItemExtensions.cs
index 4bf4f7575..918780f4a 100644
--- a/src/Services/Ordering/Ordering.API/Extensions/BasketItemExtensions.cs
+++ b/src/Services/Ordering/Ordering.API/Extensions/BasketItemExtensions.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Models;
-using static Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands.CreateOrderCommand;
public static class BasketItemExtensions
{
diff --git a/src/Services/Ordering/Ordering.API/GlobalUsings.cs b/src/Services/Ordering/Ordering.API/GlobalUsings.cs
index e1cca922a..1ae71968a 100644
--- a/src/Services/Ordering/Ordering.API/GlobalUsings.cs
+++ b/src/Services/Ordering/Ordering.API/GlobalUsings.cs
@@ -64,8 +64,6 @@ global using Microsoft.OpenApi.Models;
global using Polly.Retry;
global using Polly;
global using RabbitMQ.Client;
-global using Serilog.Context;
-global using Serilog;
global using Swashbuckle.AspNetCore.SwaggerGen;
global using System.Collections.Generic;
global using System.Data.Common;
diff --git a/src/Services/Ordering/Ordering.API/Ordering.API.csproj b/src/Services/Ordering/Ordering.API/Ordering.API.csproj
index 991dd07be..da1157d59 100644
--- a/src/Services/Ordering/Ordering.API/Ordering.API.csproj
+++ b/src/Services/Ordering/Ordering.API/Ordering.API.csproj
@@ -19,6 +19,9 @@
+
+
+
@@ -60,12 +63,6 @@
-
-
-
-
-
-
diff --git a/src/Services/Ordering/Ordering.API/Program.cs b/src/Services/Ordering/Ordering.API/Program.cs
index 0649ea2dc..c6b30c355 100644
--- a/src/Services/Ordering/Ordering.API/Program.cs
+++ b/src/Services/Ordering/Ordering.API/Program.cs
@@ -24,14 +24,10 @@ builder.WebHost.ConfigureKestrel(options =>
});
});
-builder.Host.UseSerilog(CreateSerilogLogger(builder.Configuration));
+builder.Services.AddGrpc(options => options.EnableDetailedErrors = true);
+builder.Services.AddApplicationInsightsTelemetry(builder.Configuration);
+builder.Services.AddApplicationInsightsKubernetesEnricher();
builder.Services
- .AddGrpc(options =>
- {
- options.EnableDetailedErrors = true;
- })
- .Services
- .AddApplicationInsights(builder.Configuration)
.AddCustomMvc()
.AddHealthChecks(builder.Configuration)
.AddCustomDbContext(builder.Configuration)
@@ -58,41 +54,6 @@ var services = builder.Services;
cfg.AddOpenBehavior(typeof(TransactionBehavior<,>));
});
-/*
- // Register all the command handlers.
- services.AddSingleton, CancelOrderCommandHandler>();
- services.AddSingleton, bool>, CancelOrderIdentifiedCommandHandler>();
-
- services.AddSingleton, CreateOrderCommandHandler>();
- services.AddSingleton, bool>, CreateOrderIdentifiedCommandHandler>();
-
- services.AddSingleton, CreateOrderDraftCommandHandler>();
-
- services.AddSingleton, bool>, SetAwaitingValidationIdentifiedOrderStatusCommandHandler>();
- services.AddSingleton, SetAwaitingValidationOrderStatusCommandHandler>();
-
- services.AddSingleton, bool>, SetPaidIdentifiedOrderStatusCommandHandler>();
- services.AddSingleton, SetPaidOrderStatusCommandHandler>();
-
- services.AddSingleton, bool>, SetStockConfirmedOrderStatusIdentifiedCommandHandler>();
- services.AddSingleton, SetStockConfirmedOrderStatusCommandHandler>();
-
- services.AddSingleton, bool>, SetStockRejectedOrderStatusIdentifiedCommandHandler>();
- services.AddSingleton, SetStockRejectedOrderStatusCommandHandler>();
-
- services.AddSingleton, bool>, ShipOrderIdentifiedCommandHandler>();
- services.AddSingleton, ShipOrderCommandHandler>();
-
- // Register the DomainEventHandler classes (they implement INotificationHandler<>) in assembly holding the Domain Events
- services.AddSingleton, OrderCancelledDomainEventHandler>();
- services.AddSingleton, OrderShippedDomainEventHandler>();
- services.AddSingleton, OrderStatusChangedToAwaitingValidationDomainEventHandler>();
- services.AddSingleton, OrderStatusChangedToPaidDomainEventHandler>();
- services.AddSingleton, OrderStatusChangedToStockConfirmedDomainEventHandler>();
- services.AddSingleton, UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler>();
- services.AddSingleton, ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler>();
-*/
-
// Register the command validators for the validator behavior (validators based on FluentValidation library)
services.AddSingleton, CancelOrderCommandValidator>();
services.AddSingleton, CreateOrderCommandValidator>();
@@ -135,13 +96,12 @@ if (!string.IsNullOrEmpty(pathBase))
{
app.UsePathBase(pathBase);
}
-app.UseSwagger()
- .UseSwaggerUI(c =>
- {
- c.SwaggerEndpoint($"{(!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty)}/swagger/v1/swagger.json", "Ordering.API V1");
- c.OAuthClientId("orderingswaggerui");
- c.OAuthAppName("Ordering Swagger UI");
- });
+app.UseSwagger().UseSwaggerUI(c =>
+{
+ c.SwaggerEndpoint($"{(!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty)}/swagger/v1/swagger.json", "Ordering.API V1");
+ c.OAuthClientId("orderingswaggerui");
+ c.OAuthAppName("Ordering Swagger UI");
+});
app.UseRouting();
app.UseCors("CorsPolicy");
@@ -174,10 +134,9 @@ app.MapHealthChecks("/liveness", new HealthCheckOptions
Predicate = r => r.Name.Contains("self")
});
ConfigureEventBus(app);
-try
+
+using (var scope = app.Services.CreateScope())
{
- Log.Information("Applying migrations ({ApplicationContext})...", Program.AppName);
- using var scope = app.Services.CreateScope();
var context = scope.ServiceProvider.GetRequiredService();
var env = app.Services.GetService();
var settings = app.Services.GetService>();
@@ -187,21 +146,10 @@ try
await new OrderingContextSeed().SeedAsync(context, env, settings, logger);
var integEventContext = scope.ServiceProvider.GetRequiredService();
await integEventContext.Database.MigrateAsync();
+}
- Log.Information("Starting web host ({ApplicationContext})...", Program.AppName);
- await app.RunAsync();
+await app.RunAsync();
- return 0;
-}
-catch (Exception ex)
-{
- Log.Fatal(ex, "Program terminated unexpectedly ({ApplicationContext})!", Program.AppName);
- return 1;
-}
-finally
-{
- Log.CloseAndFlush();
-}
void ConfigureEventBus(IApplicationBuilder app)
{
var eventBus = app.ApplicationServices.GetRequiredService();
@@ -213,37 +161,9 @@ void ConfigureEventBus(IApplicationBuilder app)
eventBus.Subscribe>();
eventBus.Subscribe>();
}
-Serilog.ILogger CreateSerilogLogger(IConfiguration configuration)
-{
- var seqServerUrl = configuration["Serilog:SeqServerUrl"];
- var logstashUrl = configuration["Serilog:LogstashgUrl"];
- return new LoggerConfiguration()
- .MinimumLevel.Verbose()
- .Enrich.WithProperty("ApplicationContext", Program.AppName)
- .Enrich.FromLogContext()
- .WriteTo.Console()
- .WriteTo.Seq(string.IsNullOrWhiteSpace(seqServerUrl) ? "http://seq" : seqServerUrl)
- .WriteTo.Http(string.IsNullOrWhiteSpace(logstashUrl) ? "http://logstash:8080" : logstashUrl, null)
- .ReadFrom.Configuration(configuration)
- .CreateLogger();
-}
-
-public partial class Program
-{
- private static string Namespace = typeof(Program).Assembly.GetName().Name;
- public static string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1);
-}
static class CustomExtensionsMethods
{
- public static IServiceCollection AddApplicationInsights(this IServiceCollection services, IConfiguration configuration)
- {
- services.AddApplicationInsightsTelemetry(configuration);
- services.AddApplicationInsightsKubernetesEnricher();
-
- return services;
- }
-
public static IServiceCollection AddCustomMvc(this IServiceCollection services)
{
// Add framework services.
diff --git a/src/Services/Ordering/Ordering.API/appsettings.json b/src/Services/Ordering/Ordering.API/appsettings.json
index a10f3358b..19a922b58 100644
--- a/src/Services/Ordering/Ordering.API/appsettings.json
+++ b/src/Services/Ordering/Ordering.API/appsettings.json
@@ -2,18 +2,6 @@
"ConnectionString": "Server=tcp:127.0.0.1,5433;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;TrustServerCertificate=true",
"IdentityUrl": "http://localhost:5105",
"UseCustomizationData": false,
- "Serilog": {
- "SeqServerUrl": null,
- "LogstashgUrl": null,
- "MinimumLevel": {
- "Default": "Information",
- "Override": {
- "Microsoft": "Warning",
- "Microsoft.eShopOnContainers": "Information",
- "System": "Warning"
- }
- }
- },
"AzureServiceBusEnabled": false,
"SubscriptionClientName": "Ordering",
"GracePeriodTime": "1",
diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Extensions/CustomExtensionMethods.cs b/src/Services/Ordering/Ordering.BackgroundTasks/Extensions/CustomExtensionMethods.cs
index 53d3f0aea..aa05e0006 100644
--- a/src/Services/Ordering/Ordering.BackgroundTasks/Extensions/CustomExtensionMethods.cs
+++ b/src/Services/Ordering/Ordering.BackgroundTasks/Extensions/CustomExtensionMethods.cs
@@ -1,14 +1,9 @@
-using Autofac;
-using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
+using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
-using Microsoft.Extensions.Logging;
using RabbitMQ.Client;
-using Serilog;
namespace Ordering.BackgroundTasks.Extensions
{
@@ -120,23 +115,5 @@ namespace Ordering.BackgroundTasks.Extensions
return services;
}
-
- public static ILoggingBuilder UseSerilog(this ILoggingBuilder builder, IConfiguration configuration)
- {
- var seqServerUrl = configuration["Serilog:SeqServerUrl"];
- var logstashUrl = configuration["Serilog:LogstashgUrl"];
-
- Log.Logger = new LoggerConfiguration()
- .MinimumLevel.Verbose()
- .Enrich.WithProperty("ApplicationContext", Program.AppName)
- .Enrich.FromLogContext()
- .WriteTo.Console()
- .WriteTo.Seq(string.IsNullOrWhiteSpace(seqServerUrl) ? "http://seq" : seqServerUrl)
- .WriteTo.Http(string.IsNullOrWhiteSpace(logstashUrl) ? "http://logstash:8080" : logstashUrl, null)
- .ReadFrom.Configuration(configuration)
- .CreateLogger();
-
- return builder;
- }
}
}
diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/GlobalUsings.cs b/src/Services/Ordering/Ordering.BackgroundTasks/GlobalUsings.cs
index 43b0981b8..f15742736 100644
--- a/src/Services/Ordering/Ordering.BackgroundTasks/GlobalUsings.cs
+++ b/src/Services/Ordering/Ordering.BackgroundTasks/GlobalUsings.cs
@@ -1,17 +1,13 @@
-global using Autofac.Extensions.DependencyInjection;
-global using Microsoft.AspNetCore.Hosting;
+global using Microsoft.AspNetCore.Hosting;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.Hosting;
global using Ordering.BackgroundTasks.Extensions;
-global using Serilog;
global using System.IO;
global using HealthChecks.UI.Client;
global using Microsoft.AspNetCore.Builder;
global using Microsoft.AspNetCore.Diagnostics.HealthChecks;
-global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Logging;
-global using Ordering.BackgroundTasks.Extensions;
global using Ordering.BackgroundTasks.Services;
global using System;
-global using Ordering.BackgroundTasks;
\ No newline at end of file
+global using Ordering.BackgroundTasks;
diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj b/src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj
index 0b81c1cfa..1ac347d86 100644
--- a/src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj
+++ b/src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj
@@ -18,12 +18,6 @@
-
-
-
-
-
-
diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Program.cs b/src/Services/Ordering/Ordering.BackgroundTasks/Program.cs
index ef12360db..35f066fed 100644
--- a/src/Services/Ordering/Ordering.BackgroundTasks/Program.cs
+++ b/src/Services/Ordering/Ordering.BackgroundTasks/Program.cs
@@ -1,5 +1,4 @@
-var appName = "Ordering.BackgroundTasks";
-var builder = WebApplication.CreateBuilder(new WebApplicationOptions
+var builder = WebApplication.CreateBuilder(new WebApplicationOptions
{
Args = args,
ApplicationName = typeof(Program).Assembly.FullName
@@ -8,7 +7,6 @@ builder.Configuration.SetBasePath(Directory.GetCurrentDirectory());
builder.Configuration.AddJsonFile("appsettings.json", optional: true);
builder.Configuration.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: true);
builder.Configuration.AddEnvironmentVariables();
-builder.Host.UseSerilog(CreateSerilogLogger(builder.Configuration));
builder.Services.AddCustomHealthCheck(builder.Configuration)
.Configure(builder.Configuration)
.AddOptions()
@@ -35,37 +33,7 @@ app.MapHealthChecks("/liveness", new HealthCheckOptions
Predicate = r => r.Name.Contains("self")
});
-try
-{
- Log.Information("Starting web host ({ApplicationContext})...", Program.AppName);
- await app.RunAsync();
-
- return 0;
-}
-catch (Exception ex)
-{
- Log.Fatal(ex, "Program terminated unexpectedly ({ApplicationContext})!", Program.AppName);
- return 1;
-}
-finally
-{
- Log.CloseAndFlush();
-}
-
-Serilog.ILogger CreateSerilogLogger(IConfiguration configuration)
-{
- var seqServerUrl = configuration["Serilog:SeqServerUrl"];
- var logstashUrl = configuration["Serilog:LogstashgUrl"];
- return new LoggerConfiguration()
- .MinimumLevel.Verbose()
- .Enrich.WithProperty("ApplicationContext", Program.AppName)
- .Enrich.FromLogContext()
- .WriteTo.Console()
- .WriteTo.Seq(string.IsNullOrWhiteSpace(seqServerUrl) ? "http://seq" : seqServerUrl)
- .WriteTo.Http(string.IsNullOrWhiteSpace(logstashUrl) ? "http://logstash:8080" : logstashUrl, null)
- .ReadFrom.Configuration(configuration)
- .CreateLogger();
-}
+await app.RunAsync();
public partial class Program
{
diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Services/GracePeriodManagerService.cs b/src/Services/Ordering/Ordering.BackgroundTasks/Services/GracePeriodManagerService.cs
index b494377fb..a801ac831 100644
--- a/src/Services/Ordering/Ordering.BackgroundTasks/Services/GracePeriodManagerService.cs
+++ b/src/Services/Ordering/Ordering.BackgroundTasks/Services/GracePeriodManagerService.cs
@@ -36,14 +36,7 @@ namespace Ordering.BackgroundTasks.Services
_logger.LogDebug("GracePeriodManagerService background task is doing background work.");
CheckConfirmedGracePeriodOrders();
- try
- {
- await Task.Delay(_settings.CheckUpdateTime, stoppingToken);
- }
- catch (TaskCanceledException exception)
- {
- _logger.LogCritical(exception, "TaskCanceledException Error", exception.Message);
- }
+ await Task.Delay(_settings.CheckUpdateTime, stoppingToken);
}
_logger.LogDebug("GracePeriodManagerService background task is stopping.");
@@ -59,7 +52,7 @@ namespace Ordering.BackgroundTasks.Services
{
var confirmGracePeriodEvent = new GracePeriodConfirmedIntegrationEvent(orderId);
- _logger.LogInformation("----- Publishing integration event: {IntegrationEventId} from {AppName} - ({@IntegrationEvent})", confirmGracePeriodEvent.Id, Program.AppName, confirmGracePeriodEvent);
+ _logger.LogInformation("----- Publishing integration event: {IntegrationEventId} - ({@IntegrationEvent})", confirmGracePeriodEvent.Id, confirmGracePeriodEvent);
_eventBus.Publish(confirmGracePeriodEvent);
}
diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/appsettings.json b/src/Services/Ordering/Ordering.BackgroundTasks/appsettings.json
index 88e5d6858..2069c7db2 100644
--- a/src/Services/Ordering/Ordering.BackgroundTasks/appsettings.json
+++ b/src/Services/Ordering/Ordering.BackgroundTasks/appsettings.json
@@ -1,17 +1,5 @@
{
"ConnectionString": "Server=tcp:127.0.0.1,5433;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;",
- "Serilog": {
- "SeqServerUrl": null,
- "LogstashgUrl": null,
- "MinimumLevel": {
- "Default": "Information",
- "Override": {
- "Microsoft": "Warning",
- "Microsoft.eShopOnContainers": "Information",
- "System": "Warning"
- }
- }
- },
"SubscriptionClientName": "BackgroundTasks",
"GracePeriodTime": "1",
"CheckUpdateTime": "1000",
diff --git a/src/Services/Ordering/Ordering.FunctionalTests/OrderingScenarioBase.cs b/src/Services/Ordering/Ordering.FunctionalTests/OrderingScenarioBase.cs
index 81832f32e..2bf493a4d 100644
--- a/src/Services/Ordering/Ordering.FunctionalTests/OrderingScenarioBase.cs
+++ b/src/Services/Ordering/Ordering.FunctionalTests/OrderingScenarioBase.cs
@@ -3,40 +3,49 @@ using Microsoft.Extensions.Hosting;
namespace Ordering.FunctionalTests;
-public class OrderingScenarioBase : WebApplicationFactory
+public class OrderingScenarioBase
{
- public TestServer CreateServer()
+ private class OrderingApplication : WebApplicationFactory
{
- Services.MigrateDbContext((context, services) =>
+ public TestServer CreateServer()
{
- var env = services.GetService();
- var settings = services.GetService>();
- var logger = services.GetService>();
+ Services.MigrateDbContext((context, services) =>
+ {
+ var env = services.GetService();
+ var settings = services.GetService>();
+ var logger = services.GetService>();
- new OrderingContextSeed()
- .SeedAsync(context, env, settings, logger)
- .Wait();
- })
- .MigrateDbContext((_, __) => { });
+ new OrderingContextSeed()
+ .SeedAsync(context, env, settings, logger)
+ .Wait();
+ })
+ .MigrateDbContext((_, __) => { });
- return Server;
- }
+ return Server;
+ }
- protected override IHost CreateHost(IHostBuilder builder)
- {
- builder.ConfigureServices(servies =>
+ protected override IHost CreateHost(IHostBuilder builder)
{
- servies.AddSingleton();
- });
+ builder.ConfigureServices(servies =>
+ {
+ servies.AddSingleton();
+ });
- builder.ConfigureAppConfiguration(c =>
- {
- var directory = Path.GetDirectoryName(typeof(OrderingScenarioBase).Assembly.Location)!;
+ builder.ConfigureAppConfiguration(c =>
+ {
+ var directory = Path.GetDirectoryName(typeof(OrderingScenarioBase).Assembly.Location)!;
+
+ c.AddJsonFile(Path.Combine(directory, "appsettings.json"), optional: false);
+ });
- c.AddJsonFile(Path.Combine(directory, "appsettings.json"), optional: false);
- });
+ return base.CreateHost(builder);
+ }
+ }
- return base.CreateHost(builder);
+ public TestServer CreateServer()
+ {
+ var factory = new OrderingApplication();
+ return factory.CreateServer();
}
public static class Get
diff --git a/src/Services/Ordering/Ordering.SignalrHub/GlobalUsings.cs b/src/Services/Ordering/Ordering.SignalrHub/GlobalUsings.cs
index b913f56bf..a6c14a022 100644
--- a/src/Services/Ordering/Ordering.SignalrHub/GlobalUsings.cs
+++ b/src/Services/Ordering/Ordering.SignalrHub/GlobalUsings.cs
@@ -23,8 +23,7 @@ global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.AutofacMod
global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling;
global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub;
global using RabbitMQ.Client;
-global using Serilog.Context;
-global using Serilog;
+global using System.Collections.Generic;
global using System.IdentityModel.Tokens.Jwt;
global using System.IO;
global using System.Reflection;
diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs
index f42889d98..9c460365c 100644
--- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs
+++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs
@@ -16,9 +16,9 @@ public class OrderStatusChangedToAwaitingValidationIntegrationEventHandler : IIn
public async Task Handle(OrderStatusChangedToAwaitingValidationIntegrationEvent @event)
{
- using (LogContext.PushProperty("IntegrationEventContext", @event.Id))
+ using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) }))
{
- _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
+ _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event);
await _hubContext.Clients
.Group(@event.BuyerName)
diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToCancelledIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToCancelledIntegrationEventHandler.cs
index fa2b75ebc..1c3ea4623 100644
--- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToCancelledIntegrationEventHandler.cs
+++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToCancelledIntegrationEventHandler.cs
@@ -1,4 +1,6 @@
-namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling;
+using System.Collections.Generic;
+
+namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling;
public class OrderStatusChangedToCancelledIntegrationEventHandler : IIntegrationEventHandler
{
@@ -16,13 +18,13 @@ public class OrderStatusChangedToCancelledIntegrationEventHandler : IIntegration
public async Task Handle(OrderStatusChangedToCancelledIntegrationEvent @event)
{
- using (LogContext.PushProperty("IntegrationEventContext", @event.Id))
+ using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) }))
{
- _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
+ _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event);
await _hubContext.Clients
.Group(@event.BuyerName)
.SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus });
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs
index bc8ea3d4b..fe66f7dbe 100644
--- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs
+++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs
@@ -1,4 +1,6 @@
-namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling;
+using System.Collections.Generic;
+
+namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling;
public class OrderStatusChangedToPaidIntegrationEventHandler : IIntegrationEventHandler
{
@@ -16,9 +18,9 @@ public class OrderStatusChangedToPaidIntegrationEventHandler : IIntegrationEvent
public async Task Handle(OrderStatusChangedToPaidIntegrationEvent @event)
{
- using (LogContext.PushProperty("IntegrationEventContext", @event.Id))
+ using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) }))
{
- _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
+ _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event);
await _hubContext.Clients
.Group(@event.BuyerName)
diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToShippedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToShippedIntegrationEventHandler.cs
index f6356268d..2f612bbfb 100644
--- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToShippedIntegrationEventHandler.cs
+++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToShippedIntegrationEventHandler.cs
@@ -13,12 +13,11 @@ public class OrderStatusChangedToShippedIntegrationEventHandler : IIntegrationEv
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
-
public async Task Handle(OrderStatusChangedToShippedIntegrationEvent @event)
{
- using (LogContext.PushProperty("IntegrationEventContext", @event.Id))
+ using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) }))
{
- _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
+ _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event);
await _hubContext.Clients
.Group(@event.BuyerName)
diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs
index 3289dff9a..7deb6c854 100644
--- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs
+++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs
@@ -1,4 +1,6 @@
-namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling;
+using System.Collections.Generic;
+
+namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling;
public class OrderStatusChangedToStockConfirmedIntegrationEventHandler :
IIntegrationEventHandler
@@ -17,9 +19,9 @@ public class OrderStatusChangedToStockConfirmedIntegrationEventHandler :
public async Task Handle(OrderStatusChangedToStockConfirmedIntegrationEvent @event)
{
- using (LogContext.PushProperty("IntegrationEventContext", @event.Id))
+ using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) }))
{
- _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
+ _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event);
await _hubContext.Clients
.Group(@event.BuyerName)
diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToSubmittedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToSubmittedIntegrationEventHandler.cs
index 144a5e7c6..0fa7ad8a5 100644
--- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToSubmittedIntegrationEventHandler.cs
+++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToSubmittedIntegrationEventHandler.cs
@@ -1,3 +1,5 @@
+using System.Collections.Generic;
+
namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling;
public class OrderStatusChangedToSubmittedIntegrationEventHandler :
@@ -17,9 +19,9 @@ public class OrderStatusChangedToSubmittedIntegrationEventHandler :
public async Task Handle(OrderStatusChangedToSubmittedIntegrationEvent @event)
{
- using (LogContext.PushProperty("IntegrationEventContext", @event.Id))
+ using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) }))
{
- _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
+ _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event);
await _hubContext.Clients
.Group(@event.BuyerName)
diff --git a/src/Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj b/src/Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj
index 92e65dd6b..787776c41 100644
--- a/src/Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj
+++ b/src/Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj
@@ -23,12 +23,6 @@
-
-
-
-
-
-
diff --git a/src/Services/Ordering/Ordering.SignalrHub/Program.cs b/src/Services/Ordering/Ordering.SignalrHub/Program.cs
index 03288fe33..00b61d63b 100644
--- a/src/Services/Ordering/Ordering.SignalrHub/Program.cs
+++ b/src/Services/Ordering/Ordering.SignalrHub/Program.cs
@@ -8,7 +8,6 @@ builder.Configuration.SetBasePath(Directory.GetCurrentDirectory());
builder.Configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
builder.Configuration.AddEnvironmentVariables();
builder.WebHost.CaptureStartupErrors(false);
-builder.Host.UseSerilog(CreateSerilogLogger(builder.Configuration));
builder.Services
.AddCustomHealthCheck(builder.Configuration)
@@ -110,22 +109,8 @@ app.MapHealthChecks("/liveness", new HealthCheckOptions
app.MapHub("/hub/notificationhub");
ConfigureEventBus(app);
-try
-{
- Log.Information("Starting web host ({ApplicationContext})...", Program.AppName);
- await app.RunAsync();
+await app.RunAsync();
- return 0;
-}
-catch (Exception ex)
-{
- Log.Fatal(ex, "Program terminated unexpectedly ({ApplicationContext})!", Program.AppName);
- return 1;
-}
-finally
-{
- Log.CloseAndFlush();
-}
void ConfigureEventBus(IApplicationBuilder app)
{
var eventBus = app.ApplicationServices.GetRequiredService();
@@ -137,6 +122,7 @@ void ConfigureEventBus(IApplicationBuilder app)
eventBus.Subscribe();
eventBus.Subscribe();
}
+
void ConfigureAuthService(IServiceCollection services, IConfiguration configuration)
{
// prevent from mapping "sub" claim to nameidentifier.
@@ -210,20 +196,6 @@ void RegisterEventBus(IServiceCollection services, IConfiguration configuration)
services.AddSingleton();
}
-static Serilog.ILogger CreateSerilogLogger(IConfiguration configuration)
-{
- var seqServerUrl = configuration["Serilog:SeqServerUrl"];
- var logstashUrl = configuration["Serilog:LogstashgUrl"];
- return new LoggerConfiguration()
- .MinimumLevel.Verbose()
- .Enrich.WithProperty("ApplicationContext", Program.AppName)
- .Enrich.FromLogContext()
- .WriteTo.Console()
- .WriteTo.Seq(string.IsNullOrWhiteSpace(seqServerUrl) ? "http://seq" : seqServerUrl)
- .WriteTo.Http(string.IsNullOrWhiteSpace(logstashUrl) ? "http://logstash:8080" : logstashUrl, null)
- .ReadFrom.Configuration(configuration)
- .CreateLogger();
-}
public partial class Program
{
public static string Namespace = typeof(Program).Assembly.GetName().Name;
diff --git a/src/Services/Ordering/Ordering.SignalrHub/appsettings.json b/src/Services/Ordering/Ordering.SignalrHub/appsettings.json
index e43c354a3..be528bb8b 100644
--- a/src/Services/Ordering/Ordering.SignalrHub/appsettings.json
+++ b/src/Services/Ordering/Ordering.SignalrHub/appsettings.json
@@ -1,17 +1,5 @@
{
"IdentityUrl": "http://localhost:5105",
- "Serilog": {
- "SeqServerUrl": null,
- "LogstashgUrl": null,
- "MinimumLevel": {
- "Default": "Information",
- "Override": {
- "Microsoft": "Warning",
- "Microsoft.eShopOnContainers": "Information",
- "System": "Warning"
- }
- }
- },
"AzureServiceBusEnabled": false,
"SubscriptionClientName": "Ordering.signalrhub",
"EventBusRetryCount": 5,
diff --git a/src/Services/Payment/Payment.API/GlobalUsings.cs b/src/Services/Payment/Payment.API/GlobalUsings.cs
index 01ba3682b..b064110ab 100644
--- a/src/Services/Payment/Payment.API/GlobalUsings.cs
+++ b/src/Services/Payment/Payment.API/GlobalUsings.cs
@@ -20,8 +20,6 @@ global using Microsoft.Extensions.Logging;
global using Microsoft.eShopOnContainers.Payment.API.IntegrationEvents.EventHandling;
global using Microsoft.eShopOnContainers.Payment.API;
global using RabbitMQ.Client;
-global using Serilog.Context;
-global using Serilog;
global using System.Threading.Tasks;
global using System;
global using System.IO;
diff --git a/src/Services/Payment/Payment.API/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs b/src/Services/Payment/Payment.API/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs
index 0712f8908..d88bad3db 100644
--- a/src/Services/Payment/Payment.API/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs
+++ b/src/Services/Payment/Payment.API/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs
@@ -1,4 +1,6 @@
-namespace Microsoft.eShopOnContainers.Payment.API.IntegrationEvents.EventHandling;
+using System.Collections.Generic;
+
+namespace Microsoft.eShopOnContainers.Payment.API.IntegrationEvents.EventHandling;
public class OrderStatusChangedToStockConfirmedIntegrationEventHandler :
IIntegrationEventHandler
@@ -21,9 +23,9 @@ public class OrderStatusChangedToStockConfirmedIntegrationEventHandler :
public async Task Handle(OrderStatusChangedToStockConfirmedIntegrationEvent @event)
{
- using (LogContext.PushProperty("IntegrationEventContext", @event.Id))
+ using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) }))
{
- _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
+ _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event);
IntegrationEvent orderPaymentIntegrationEvent;
@@ -42,7 +44,7 @@ public class OrderStatusChangedToStockConfirmedIntegrationEventHandler :
orderPaymentIntegrationEvent = new OrderPaymentFailedIntegrationEvent(@event.OrderId);
}
- _logger.LogInformation("----- Publishing integration event: {IntegrationEventId} from {AppName} - ({@IntegrationEvent})", orderPaymentIntegrationEvent.Id, Program.AppName, orderPaymentIntegrationEvent);
+ _logger.LogInformation("----- Publishing integration event: {IntegrationEventId} - ({@IntegrationEvent})", orderPaymentIntegrationEvent.Id, orderPaymentIntegrationEvent);
_eventBus.Publish(orderPaymentIntegrationEvent);
diff --git a/src/Services/Payment/Payment.API/Payment.API.csproj b/src/Services/Payment/Payment.API/Payment.API.csproj
index 61cfd2050..4e72c131e 100644
--- a/src/Services/Payment/Payment.API/Payment.API.csproj
+++ b/src/Services/Payment/Payment.API/Payment.API.csproj
@@ -20,12 +20,6 @@
-
-
-
-
-
-
diff --git a/src/Services/Payment/Payment.API/Program.cs b/src/Services/Payment/Payment.API/Program.cs
index e6f92f4e3..60c7d947f 100644
--- a/src/Services/Payment/Payment.API/Program.cs
+++ b/src/Services/Payment/Payment.API/Program.cs
@@ -1,9 +1,4 @@
-var builder = WebApplication.CreateBuilder(new WebApplicationOptions
-{
- Args = args,
- ApplicationName = typeof(Program).Assembly.FullName,
- ContentRootPath = Directory.GetCurrentDirectory()
-});
+var builder = WebApplication.CreateBuilder(args);
if (builder.Configuration.GetValue("UseVault", false))
{
TokenCredential credential = new ClientSecretCredential(
@@ -16,7 +11,6 @@ builder.Configuration.SetBasePath(Directory.GetCurrentDirectory());
builder.Configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
builder.Configuration.AddEnvironmentVariables();
builder.WebHost.CaptureStartupErrors(false);
-builder.Host.UseSerilog(CreateSerilogLogger(builder.Configuration));
builder.Services
.AddCustomHealthCheck(builder.Configuration);
builder.Services.Configure(builder.Configuration);
@@ -88,22 +82,8 @@ app.MapHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
-try
-{
- Log.Information("Starting web host ({ApplicationContext})...", Program.AppName);
- await app.RunAsync();
- return 0;
-}
-catch (Exception ex)
-{
- Log.Fatal(ex, "Program terminated unexpectedly ({ApplicationContext})!", Program.AppName);
- return 1;
-}
-finally
-{
- Log.CloseAndFlush();
-}
+await app.RunAsync();
void RegisterEventBus(IServiceCollection services)
{
@@ -149,21 +129,6 @@ void ConfigureEventBus(IApplicationBuilder app)
eventBus.Subscribe();
}
-Serilog.ILogger CreateSerilogLogger(IConfiguration configuration)
-{
- var seqServerUrl = configuration["Serilog:SeqServerUrl"];
- var logstashUrl = configuration["Serilog:LogstashgUrl"];
- return new LoggerConfiguration()
- .MinimumLevel.Verbose()
- .Enrich.WithProperty("ApplicationContext", Program.AppName)
- .Enrich.FromLogContext()
- .WriteTo.Console()
- .WriteTo.Seq(string.IsNullOrWhiteSpace(seqServerUrl) ? "http://seq" : seqServerUrl)
- .WriteTo.Http(string.IsNullOrWhiteSpace(logstashUrl) ? "http://logstash:8080" : logstashUrl, null)
- .ReadFrom.Configuration(configuration)
- .CreateLogger();
-}
-
public partial class Program
{
public static string Namespace = typeof(Program).Assembly.GetName().Name;
diff --git a/src/Services/Payment/Payment.API/appsettings.json b/src/Services/Payment/Payment.API/appsettings.json
index 9964a8bd2..41de245fb 100644
--- a/src/Services/Payment/Payment.API/appsettings.json
+++ b/src/Services/Payment/Payment.API/appsettings.json
@@ -1,16 +1,4 @@
{
- "Serilog": {
- "SeqServerUrl": null,
- "LogstashgUrl": null,
- "MinimumLevel": {
- "Default": "Information",
- "Override": {
- "Microsoft": "Warning",
- "Microsoft.eShopOnContainers": "Information",
- "System": "Warning"
- }
- }
- },
"PaymentSucceeded": true,
"AzureServiceBusEnabled": false,
"SubscriptionClientName": "Payment",
diff --git a/src/Services/Services.Common/CommonExtensions.cs b/src/Services/Services.Common/CommonExtensions.cs
index 7971b11a3..5a5e52cd7 100644
--- a/src/Services/Services.Common/CommonExtensions.cs
+++ b/src/Services/Services.Common/CommonExtensions.cs
@@ -16,7 +16,6 @@ using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using RabbitMQ.Client;
-using Serilog;
namespace Services.Common;
@@ -33,11 +32,6 @@ public static class CommonExtensions
// Default health checks assume the event bus and self health checks
builder.Services.AddDefaultHealthChecks(builder.Configuration);
- // Configure the default logging for this application
- // builder.Host.UseDefaultSerilog(builder.Configuration, builder.Environment.ApplicationName);
-
- // Customizations for this application
-
// Add the event bus
builder.Services.AddEventBus(builder.Configuration);
@@ -388,36 +382,6 @@ public static class CommonExtensions
return services;
}
- public static void UseDefaultSerilog(this IHostBuilder builder, IConfiguration configuration, string name)
- {
- builder.UseSerilog(CreateSerilogLogger(configuration));
-
- Serilog.ILogger CreateSerilogLogger(IConfiguration configuration)
- {
- var seqServerUrl = configuration["Serilog:SeqServerUrl"];
- var logstashUrl = configuration["Serilog:LogstashgUrl"];
-
- var loggingConfiguration = new LoggerConfiguration()
- .MinimumLevel.Verbose()
- .Enrich.WithProperty("ApplicationContext", name)
- .Enrich.FromLogContext()
- .WriteTo.Console()
- .ReadFrom.Configuration(configuration);
-
- if (!string.IsNullOrEmpty(seqServerUrl))
- {
- loggingConfiguration.WriteTo.Seq(seqServerUrl);
- }
-
- if (!string.IsNullOrEmpty(logstashUrl))
- {
- loggingConfiguration.WriteTo.Http(logstashUrl, null);
- }
-
- return loggingConfiguration.CreateLogger();
- }
- }
-
public static void MapDefaultHealthChecks(this IEndpointRouteBuilder routes)
{
routes.MapHealthChecks("/hc", new HealthCheckOptions()
diff --git a/src/Services/Services.Common/Services.Common.csproj b/src/Services/Services.Common/Services.Common.csproj
index 0eb7de774..89ff64893 100644
--- a/src/Services/Services.Common/Services.Common.csproj
+++ b/src/Services/Services.Common/Services.Common.csproj
@@ -41,12 +41,6 @@
-
-
-
-
-
-
diff --git a/src/Web/WebMVC/Controllers/AccountController.cs b/src/Web/WebMVC/Controllers/AccountController.cs
index 78282f9a9..9daf98275 100644
--- a/src/Web/WebMVC/Controllers/AccountController.cs
+++ b/src/Web/WebMVC/Controllers/AccountController.cs
@@ -16,7 +16,7 @@ public class AccountController : Controller
var user = User as ClaimsPrincipal;
var token = await HttpContext.GetTokenAsync("access_token");
- _logger.LogInformation("----- User {@User} authenticated into {AppName}", user, Program.AppName);
+ _logger.LogInformation("----- User {@User} authenticated", user);
if (token != null)
{
diff --git a/src/Web/WebMVC/Infrastructure/WebContextSeed.cs b/src/Web/WebMVC/Infrastructure/WebContextSeed.cs
index cc03c1797..c20f39690 100644
--- a/src/Web/WebMVC/Infrastructure/WebContextSeed.cs
+++ b/src/Web/WebMVC/Infrastructure/WebContextSeed.cs
@@ -1,14 +1,12 @@
namespace WebMVC.Infrastructure;
-using Serilog;
public class WebContextSeed
{
public static void Seed(IApplicationBuilder applicationBuilder, IWebHostEnvironment env)
{
- var log = Log.Logger;
-
- var settings = (AppSettings)applicationBuilder
+ var settings = applicationBuilder
.ApplicationServices.GetRequiredService>().Value;
+ var log = applicationBuilder.ApplicationServices.GetRequiredService>();
var useCustomizationData = settings.UseCustomizationData;
var contentRootPath = env.ContentRootPath;
@@ -29,7 +27,7 @@ public class WebContextSeed
string overrideCssFile = Path.Combine(contentRootPath, "Setup", "override.css");
if (!File.Exists(overrideCssFile))
{
- log.Error("Override css file '{FileName}' does not exists.", overrideCssFile);
+ log.LogError("Override css file '{FileName}' does not exists.", overrideCssFile);
return;
}
@@ -38,7 +36,7 @@ public class WebContextSeed
}
catch (Exception ex)
{
- log.Error(ex, "EXCEPTION ERROR: {Message}", ex.Message);
+ log.LogError(ex, "Error getting preconfigured css");
}
}
@@ -49,7 +47,7 @@ public class WebContextSeed
string imagesZipFile = Path.Combine(contentRootPath, "Setup", "images.zip");
if (!File.Exists(imagesZipFile))
{
- log.Error("Zip file '{ZipFileName}' does not exists.", imagesZipFile);
+ log.LogError("Zip file '{ZipFileName}' does not exists.", imagesZipFile);
return;
}
@@ -70,14 +68,14 @@ public class WebContextSeed
}
else
{
- log.Warning("Skipped file '{FileName}' in zipfile '{ZipFileName}'", entry.Name, imagesZipFile);
+ log.LogWarning("Skipped file '{FileName}' in zip file '{ZipFileName}'", entry.Name, imagesZipFile);
}
}
}
catch (Exception ex)
{
- log.Error(ex, "EXCEPTION ERROR: {Message}", ex.Message);
+ log.LogError(ex, "Error getting preconfigured images");
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Web/WebMVC/Program.cs b/src/Web/WebMVC/Program.cs
index ae56982a6..3d5eb1511 100644
--- a/src/Web/WebMVC/Program.cs
+++ b/src/Web/WebMVC/Program.cs
@@ -8,7 +8,6 @@ AddHttpClientServices(builder);
AddCustomAuthentication(builder);
builder.WebHost.CaptureStartupErrors(false);
-builder.Host.UseSerilog(CreateSerilogLogger(builder.Configuration));
var app = builder.Build();
@@ -58,26 +57,6 @@ app.MapHealthChecks("/hc", new HealthCheckOptions()
await app.RunAsync();
-Serilog.ILogger CreateSerilogLogger(IConfiguration configuration)
-{
- var seqServerUrl = configuration["Serilog:SeqServerUrl"];
- var logstashUrl = configuration["Serilog:LogstashgUrl"];
- var cfg = new LoggerConfiguration()
- .ReadFrom.Configuration(configuration)
- .Enrich.WithProperty("ApplicationContext", AppName)
- .Enrich.FromLogContext()
- .WriteTo.Console();
- if (!string.IsNullOrWhiteSpace(seqServerUrl))
- {
- cfg.WriteTo.Seq(seqServerUrl);
- }
- if (!string.IsNullOrWhiteSpace(logstashUrl))
- {
- cfg.WriteTo.Http(logstashUrl, null);
- }
- return cfg.CreateLogger();
-}
-
static void AddApplicationInsights(WebApplicationBuilder builder)
{
builder.Services.AddApplicationInsightsTelemetry(builder.Configuration);
@@ -174,4 +153,4 @@ static void AddCustomAuthentication(WebApplicationBuilder builder)
public partial class Program
{
public static readonly string AppName = typeof(Program).Assembly.GetName().Name;
-}
\ No newline at end of file
+}
diff --git a/src/Web/WebMVC/WebMVC.csproj b/src/Web/WebMVC/WebMVC.csproj
index da5b499f6..e0b3fff05 100644
--- a/src/Web/WebMVC/WebMVC.csproj
+++ b/src/Web/WebMVC/WebMVC.csproj
@@ -35,12 +35,6 @@
-
-
-
-
-
-
diff --git a/src/Web/WebMVC/appsettings.Development.json b/src/Web/WebMVC/appsettings.Development.json
index a96c927e8..0f530c147 100644
--- a/src/Web/WebMVC/appsettings.Development.json
+++ b/src/Web/WebMVC/appsettings.Development.json
@@ -1,7 +1,2 @@
{
- "Serilog": {
- "MinimumLevel": {
- "Default": "Debug"
- }
- }
}
diff --git a/src/Web/WebMVC/appsettings.json b/src/Web/WebMVC/appsettings.json
index 7c169c27c..55561ef75 100644
--- a/src/Web/WebMVC/appsettings.json
+++ b/src/Web/WebMVC/appsettings.json
@@ -9,13 +9,6 @@
"UseLoadTest": false,
"ActivateCampaignDetailFunction": "False",
"UseCustomizationData": false,
- "Serilog": {
- "SeqServerUrl": null,
- "LogstashgUrl": null,
- "MinimumLevel": {
- "Default": "Information"
- }
- },
"ApplicationInsights": {
"InstrumentationKey": ""
},
diff --git a/src/Web/WebMVC/globalusings.cs b/src/Web/WebMVC/globalusings.cs
index 4aa6c9038..aff8f2e62 100644
--- a/src/Web/WebMVC/globalusings.cs
+++ b/src/Web/WebMVC/globalusings.cs
@@ -26,7 +26,6 @@ global using Microsoft.Extensions.Hosting;
global using Microsoft.Extensions.Logging;
global using Microsoft.Extensions.Options;
global using Microsoft.IdentityModel.Logging;
-global using Serilog;
global using StackExchange.Redis;
global using System.Collections.Generic;
global using System.ComponentModel.DataAnnotations;
@@ -46,4 +45,4 @@ global using System.Threading.Tasks;
global using System.Threading;
global using System;
global using WebMVC.Infrastructure;
-global using WebMVC.Services.ModelDTOs;
\ No newline at end of file
+global using WebMVC.Services.ModelDTOs;
diff --git a/src/Web/WebSPA/GlobalUsings.cs b/src/Web/WebSPA/GlobalUsings.cs
index 0b82464fd..07c26ded8 100644
--- a/src/Web/WebSPA/GlobalUsings.cs
+++ b/src/Web/WebSPA/GlobalUsings.cs
@@ -3,7 +3,6 @@ global using Microsoft.AspNetCore;
global using Microsoft.AspNetCore.Hosting;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.Logging;
-global using Serilog;
global using System.IO;
global using eShopOnContainers.WebSPA;
global using HealthChecks.UI.Client;
diff --git a/src/Web/WebSPA/Program.cs b/src/Web/WebSPA/Program.cs
index b3cb021de..52f090b67 100644
--- a/src/Web/WebSPA/Program.cs
+++ b/src/Web/WebSPA/Program.cs
@@ -37,16 +37,6 @@ builder.Services.AddSpaStaticFiles(configuration =>
builder.Logging.AddConfiguration(builder.Configuration.GetSection("Logging"));
builder.Logging.AddAzureWebAppDiagnostics();
-builder.Host.UseSerilog((builderContext, config) =>
-{
- config
- .MinimumLevel.Information()
- .Enrich.FromLogContext()
- .WriteTo.Seq("http://seq")
- .ReadFrom.Configuration(builderContext.Configuration)
- .WriteTo.Console();
-})
-.UseConsoleLifetime();
var app = builder.Build();
diff --git a/src/Web/WebSPA/WebSPA.csproj b/src/Web/WebSPA/WebSPA.csproj
index a6c152ea2..8a842a792 100644
--- a/src/Web/WebSPA/WebSPA.csproj
+++ b/src/Web/WebSPA/WebSPA.csproj
@@ -42,9 +42,6 @@
-
-
-
diff --git a/src/Web/WebStatus/GlobalUsings.cs b/src/Web/WebStatus/GlobalUsings.cs
index 986d4ee76..0efba33ad 100644
--- a/src/Web/WebStatus/GlobalUsings.cs
+++ b/src/Web/WebStatus/GlobalUsings.cs
@@ -1,14 +1,9 @@
global using Microsoft.AspNetCore.Mvc;
global using Microsoft.Extensions.Configuration;
global using System.Linq;
-global using Microsoft.AspNetCore;
global using Microsoft.AspNetCore.Hosting;
-global using Serilog;
global using System;
global using System.Collections.Generic;
-global using System.IO;
-global using System.Reflection;
-global using WebStatus;
global using Azure.Identity;
global using Azure.Core;
global using Microsoft.AspNetCore.Builder;
@@ -16,4 +11,3 @@ global using Microsoft.AspNetCore.Diagnostics.HealthChecks;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Diagnostics.HealthChecks;
global using Microsoft.Extensions.Hosting;
-global using Microsoft.Extensions.Logging;
diff --git a/src/Web/WebStatus/Program.cs b/src/Web/WebStatus/Program.cs
index 6cfbc1d1e..ddecc6a9e 100644
--- a/src/Web/WebStatus/Program.cs
+++ b/src/Web/WebStatus/Program.cs
@@ -1,83 +1,60 @@
-try
+var builder = WebApplication.CreateBuilder(args);
+if (builder.Configuration.GetValue("UseVault", false))
{
- var builder = WebApplication.CreateBuilder(args);
- if (builder.Configuration.GetValue("UseVault", false))
- {
- TokenCredential credential = new ClientSecretCredential(
- builder.Configuration["Vault:TenantId"],
- builder.Configuration["Vault:ClientId"],
- builder.Configuration["Vault:ClientSecret"]);
- builder.Configuration.AddAzureKeyVault(new Uri($"https://{builder.Configuration["Vault:Name"]}.vault.azure.net/"), credential);
- }
-
- builder.Host.UseSerilog(CreateLogger(builder.Configuration));
- builder.WebHost.CaptureStartupErrors(false);
- builder.Services.AddApplicationInsightsTelemetry(builder.Configuration);
- builder.Services.AddApplicationInsightsKubernetesEnricher();
- builder.Services.AddMvc();
- builder.Services.AddOptions();
- builder.Services.AddHealthChecks()
- .AddCheck("self", () => HealthCheckResult.Healthy());
- builder.Services
- .AddHealthChecksUI()
- .AddInMemoryStorage();
-
- var app = builder.Build();
-
- if (app.Environment.IsDevelopment())
- {
- app.UseDeveloperExceptionPage();
- }
- else
- {
- app.UseExceptionHandler("/Home/Error");
- }
-
- var pathBase = app.Configuration["PATH_BASE"];
- if (!string.IsNullOrEmpty(pathBase))
- {
- app.UsePathBase(pathBase);
- }
-
- app.UseHealthChecksUI(config =>
- {
- config.ResourcesPath = string.IsNullOrEmpty(pathBase) ? "/ui/resources" : $"{pathBase}/ui/resources";
- config.UIPath = "/hc-ui";
- });
+ TokenCredential credential = new ClientSecretCredential(
+ builder.Configuration["Vault:TenantId"],
+ builder.Configuration["Vault:ClientId"],
+ builder.Configuration["Vault:ClientSecret"]);
+ builder.Configuration.AddAzureKeyVault(new Uri($"https://{builder.Configuration["Vault:Name"]}.vault.azure.net/"), credential);
+}
- app.UseStaticFiles();
+builder.WebHost.CaptureStartupErrors(false);
+builder.Services.AddApplicationInsightsTelemetry(builder.Configuration);
+builder.Services.AddApplicationInsightsKubernetesEnricher();
+builder.Services.AddMvc();
+builder.Services.AddOptions();
+builder.Services.AddHealthChecks()
+ .AddCheck("self", () => HealthCheckResult.Healthy());
+builder.Services
+ .AddHealthChecksUI()
+ .AddInMemoryStorage();
- app.UseRouting();
- app.MapDefaultControllerRoute();
- app.MapHealthChecks("/liveness", new HealthCheckOptions
- {
- Predicate = r => r.Name.Contains("self")
- });
+var app = builder.Build();
- await app.RunAsync();
+if (app.Environment.IsDevelopment())
+{
+ app.UseDeveloperExceptionPage();
}
-catch (Exception exception)
+else
{
- Console.WriteLine(exception);
+ app.UseExceptionHandler("/Home/Error");
}
-Serilog.ILogger CreateLogger(IConfiguration configuration)
+var pathBase = app.Configuration["PATH_BASE"];
+if (!string.IsNullOrEmpty(pathBase))
{
- var seqServerUrl = configuration["Serilog:SeqServerUrl"];
- var logstashUrl = configuration["Serilog:LogstashgUrl"];
- return new LoggerConfiguration()
- .MinimumLevel.Verbose()
- .Enrich.WithProperty("ApplicationContext", Program.AppName)
- .Enrich.FromLogContext()
- .WriteTo.Console()
- .WriteTo.Seq(string.IsNullOrWhiteSpace(seqServerUrl) ? "http://seq" : seqServerUrl)
- .WriteTo.Http(string.IsNullOrWhiteSpace(logstashUrl) ? "http://logstash:8080" : logstashUrl, null)
- .ReadFrom.Configuration(configuration)
- .CreateLogger();
+ app.UsePathBase(pathBase);
}
+app.UseHealthChecksUI(config =>
+{
+ config.ResourcesPath = string.IsNullOrEmpty(pathBase) ? "/ui/resources" : $"{pathBase}/ui/resources";
+ config.UIPath = "/hc-ui";
+});
+
+app.UseStaticFiles();
+
+app.UseRouting();
+app.MapDefaultControllerRoute();
+app.MapHealthChecks("/liveness", new HealthCheckOptions
+{
+ Predicate = r => r.Name.Contains("self")
+});
+
+await app.RunAsync();
+
public partial class Program
{
private static readonly string _namespace = typeof(Program).Assembly.GetName().Name;
public static readonly string AppName = _namespace;
-}
\ No newline at end of file
+}
diff --git a/src/Web/WebStatus/WebStatus.csproj b/src/Web/WebStatus/WebStatus.csproj
index 20b3e6903..22e65f96b 100644
--- a/src/Web/WebStatus/WebStatus.csproj
+++ b/src/Web/WebStatus/WebStatus.csproj
@@ -19,12 +19,6 @@
-
-
-
-
-
-
diff --git a/src/Web/WebStatus/appsettings.Development.json b/src/Web/WebStatus/appsettings.Development.json
index a96c927e8..0f530c147 100644
--- a/src/Web/WebStatus/appsettings.Development.json
+++ b/src/Web/WebStatus/appsettings.Development.json
@@ -1,7 +1,2 @@
{
- "Serilog": {
- "MinimumLevel": {
- "Default": "Debug"
- }
- }
}
diff --git a/src/Web/WebStatus/appsettings.json b/src/Web/WebStatus/appsettings.json
index a7b130e1a..e1f07fa2b 100644
--- a/src/Web/WebStatus/appsettings.json
+++ b/src/Web/WebStatus/appsettings.json
@@ -1,16 +1,4 @@
{
- "Serilog": {
- "SeqServerUrl": null,
- "LogstashgUrl": null,
- "MinimumLevel": {
- "Default": "Information",
- "Override": {
- "Microsoft": "Warning",
- "Microsoft.eShopOnContainers": "Information",
- "System": "Warning"
- }
- }
- },
"Webhooks": [
{
"Name": "",
diff --git a/src/docker-compose.override.yml b/src/docker-compose.override.yml
index dd1a95f3d..20dfee96f 100644
--- a/src/docker-compose.override.yml
+++ b/src/docker-compose.override.yml
@@ -117,8 +117,6 @@ services:
- ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY}
- OrchestratorType=${ORCHESTRATOR_TYPE}
- UseLoadTest=${USE_LOADTEST:-False}
- - Serilog__MinimumLevel__Override__Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ=Verbose
- - Serilog__MinimumLevel__Override__ordering-api=Verbose
- PATH_BASE=/ordering-api
- GRPC_PORT=81
- PORT=80
@@ -141,7 +139,6 @@ services:
- ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY}
- OrchestratorType=${ORCHESTRATOR_TYPE}
- UseLoadTest=${USE_LOADTEST:-False}
- - Serilog__MinimumLevel__Override__Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ=Verbose
ports:
- "5111:80"
@@ -155,8 +152,6 @@ services:
- AzureServiceBusEnabled=False
- ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY}
- OrchestratorType=${ORCHESTRATOR_TYPE}
- - Serilog__MinimumLevel__Override__payment-api.IntegrationEvents.EventHandling=Verbose
- - Serilog__MinimumLevel__Override__Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ=Verbose
ports:
- "5108:80"