Fix non-structured traces

This commit is contained in:
Miguel Veloso 2019-02-22 15:05:28 +00:00
parent dfc680e152
commit 63a325e92e
25 changed files with 78 additions and 77 deletions

View File

@ -57,7 +57,7 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator
if (!string.IsNullOrEmpty(pathBase)) if (!string.IsNullOrEmpty(pathBase))
{ {
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'"); loggerFactory.CreateLogger<Startup>().LogDebug("Using PATH BASE '{pathBase}'", pathBase);
app.UsePathBase(pathBase); app.UsePathBase(pathBase);
} }

View File

@ -57,7 +57,7 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator
var pathBase = Configuration["PATH_BASE"]; var pathBase = Configuration["PATH_BASE"];
if (!string.IsNullOrEmpty(pathBase)) if (!string.IsNullOrEmpty(pathBase))
{ {
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'"); loggerFactory.CreateLogger<Startup>().LogDebug("Using PATH BASE '{pathBase}'", pathBase);
app.UsePathBase(pathBase); app.UsePathBase(pathBase);
} }

View File

@ -83,7 +83,7 @@
} }
catch (ServiceBusException) catch (ServiceBusException)
{ {
_logger.LogInformation($"The messaging entity {eventName} already exists."); _logger.LogWarning("The messaging entity {eventName} already exists.", eventName);
} }
} }
@ -105,7 +105,7 @@
} }
catch (MessagingEntityNotFoundException) catch (MessagingEntityNotFoundException)
{ {
_logger.LogInformation($"The messaging entity {eventName} Could not be found."); _logger.LogWarning("The messaging entity {eventName} Could not be found.", eventName);
} }
_subsManager.RemoveSubscription<T, TH>(); _subsManager.RemoveSubscription<T, TH>();
@ -194,7 +194,7 @@
} }
catch (MessagingEntityNotFoundException) catch (MessagingEntityNotFoundException)
{ {
_logger.LogInformation($"The messaging entity { RuleDescription.DefaultRuleName } Could not be found."); _logger.LogWarning("The messaging entity {DefaultRuleName} Could not be found.", RuleDescription.DefaultRuleName);
} }
} }
} }

View File

@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Hosting
try try
{ {
logger.LogInformation($"Migrating database associated with context {typeof(TContext).Name}"); logger.LogInformation("Migrating database associated with context {DbContextName}", typeof(TContext).Name);
var retry = Policy.Handle<SqlException>() var retry = Policy.Handle<SqlException>()
.WaitAndRetry(new TimeSpan[] .WaitAndRetry(new TimeSpan[]
@ -45,11 +45,11 @@ namespace Microsoft.AspNetCore.Hosting
}); });
logger.LogInformation($"Migrated database associated with context {typeof(TContext).Name}"); logger.LogInformation("Migrated database associated with context {DbContextName}", typeof(TContext).Name);
} }
catch (Exception ex) catch (Exception ex)
{ {
logger.LogError(ex, $"An error occurred while migrating the database used on context {typeof(TContext).Name}"); logger.LogError(ex, "An error occurred while migrating the database used on context {DbContextName}", typeof(TContext).Name);
} }
} }

View File

@ -76,14 +76,14 @@
} }
catch (Exception ex) catch (Exception ex)
{ {
logger.LogError(ex.Message); logger.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message);
return GetPreconfiguredCatalogBrands(); return GetPreconfiguredCatalogBrands();
} }
return File.ReadAllLines(csvFileCatalogBrands) return File.ReadAllLines(csvFileCatalogBrands)
.Skip(1) // skip header row .Skip(1) // skip header row
.SelectTry(x => CreateCatalogBrand(x)) .SelectTry(x => CreateCatalogBrand(x))
.OnCaughtException(ex => { logger.LogError(ex.Message); return null; }) .OnCaughtException(ex => { logger.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); return null; })
.Where(x => x != null); .Where(x => x != null);
} }
@ -131,14 +131,14 @@
} }
catch (Exception ex) catch (Exception ex)
{ {
logger.LogError(ex.Message); logger.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message);
return GetPreconfiguredCatalogTypes(); return GetPreconfiguredCatalogTypes();
} }
return File.ReadAllLines(csvFileCatalogTypes) return File.ReadAllLines(csvFileCatalogTypes)
.Skip(1) // skip header row .Skip(1) // skip header row
.SelectTry(x => CreateCatalogType(x)) .SelectTry(x => CreateCatalogType(x))
.OnCaughtException(ex => { logger.LogError(ex.Message); return null; }) .OnCaughtException(ex => { logger.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); return null; })
.Where(x => x != null); .Where(x => x != null);
} }
@ -186,7 +186,7 @@
} }
catch (Exception ex) catch (Exception ex)
{ {
logger.LogError(ex.Message); logger.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message);
return GetPreconfiguredItems(); return GetPreconfiguredItems();
} }
@ -197,7 +197,7 @@
.Skip(1) // skip header row .Skip(1) // skip header row
.Select(row => Regex.Split(row, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)") ) .Select(row => Regex.Split(row, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)") )
.SelectTry(column => CreateCatalogItem(column, csvheaders, catalogTypeIdLookup, catalogBrandIdLookup)) .SelectTry(column => CreateCatalogItem(column, csvheaders, catalogTypeIdLookup, catalogBrandIdLookup))
.OnCaughtException(ex => { logger.LogError(ex.Message); return null; }) .OnCaughtException(ex => { logger.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); return null; })
.Where(x => x != null); .Where(x => x != null);
} }
@ -377,7 +377,7 @@
sleepDurationProvider: retry => TimeSpan.FromSeconds(5), sleepDurationProvider: retry => TimeSpan.FromSeconds(5),
onRetry: (exception, timeSpan, retry, ctx) => onRetry: (exception, timeSpan, retry, ctx) =>
{ {
logger.LogTrace($"[{prefix}] Exception {exception.GetType().Name} with message ${exception.Message} detected on attempt {retry} of {retries}"); logger.LogWarning(exception, "[{prefix}] Exception {ExceptionType} with message {Message} detected on attempt {retry} of {retries}", prefix, exception.GetType().Name, exception.Message, retry, retries);
} }
); );
} }

View File

@ -71,7 +71,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API
if (!string.IsNullOrEmpty(pathBase)) if (!string.IsNullOrEmpty(pathBase))
{ {
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'"); loggerFactory.CreateLogger<Startup>().LogDebug("Using PATH BASE '{pathBase}'", pathBase);
app.UsePathBase(pathBase); app.UsePathBase(pathBase);
} }

View File

@ -51,7 +51,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data
{ {
retryForAvaiability++; retryForAvaiability++;
logger.LogError(ex.Message,$"There is an error migrating data for ApplicationDbContext"); logger.LogError(ex, "EXCEPTION ERROR while migrating {DbContextName}", nameof(ApplicationDbContext));
await SeedAsync(context,env,logger,settings, retryForAvaiability); await SeedAsync(context,env,logger,settings, retryForAvaiability);
} }
@ -80,7 +80,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data
} }
catch (Exception ex) catch (Exception ex)
{ {
logger.LogError(ex.Message); logger.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message);
return GetDefaultUser(); return GetDefaultUser();
} }
@ -89,7 +89,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data
.Skip(1) // skip header column .Skip(1) // skip header column
.Select(row => Regex.Split(row, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)") ) .Select(row => Regex.Split(row, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)") )
.SelectTry(column => CreateApplicationUser(column, csvheaders)) .SelectTry(column => CreateApplicationUser(column, csvheaders))
.OnCaughtException(ex => { logger.LogError(ex.Message); return null; }) .OnCaughtException(ex => { logger.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); return null; })
.Where(x => x != null) .Where(x => x != null)
.ToList(); .ToList();
@ -199,7 +199,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data
string imagesZipFile = Path.Combine(contentRootPath, "Setup", "images.zip"); string imagesZipFile = Path.Combine(contentRootPath, "Setup", "images.zip");
if (!File.Exists(imagesZipFile)) if (!File.Exists(imagesZipFile))
{ {
logger.LogError($" zip file '{imagesZipFile}' does not exists."); logger.LogError("Zip file '{ZipFileName}' does not exists.", imagesZipFile);
return; return;
} }
@ -221,14 +221,14 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data
} }
else else
{ {
logger.LogWarning($"Skip file '{entry.Name}' in zipfile '{imagesZipFile}'"); logger.LogWarning("Skipped file '{FileName}' in zipfile '{ZipFileName}'", entry.Name, imagesZipFile);
} }
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
logger.LogError($"Exception in method GetPreconfiguredImages WebMVC. Exception Message={ex.Message}"); logger.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); ;
} }
} }
} }

View File

@ -136,7 +136,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API
var pathBase = Configuration["PATH_BASE"]; var pathBase = Configuration["PATH_BASE"];
if (!string.IsNullOrEmpty(pathBase)) if (!string.IsNullOrEmpty(pathBase))
{ {
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'"); loggerFactory.CreateLogger<Startup>().LogDebug("Using PATH BASE '{pathBase}'", pathBase);
app.UsePathBase(pathBase); app.UsePathBase(pathBase);
} }

View File

@ -76,7 +76,7 @@
sleepDurationProvider: retry => TimeSpan.FromSeconds(5), sleepDurationProvider: retry => TimeSpan.FromSeconds(5),
onRetry: (exception, timeSpan, retry, ctx) => onRetry: (exception, timeSpan, retry, ctx) =>
{ {
logger.LogTrace($"[{prefix}] Exception {exception.GetType().Name} with message ${exception.Message} detected on attempt {retry} of {retries}"); logger.LogWarning(exception, "[{prefix}] Exception {ExceptionType} with message {Message} detected on attempt {retry} of {retries}", prefix, exception.GetType().Name, exception.Message, retry, retries);
} }
); );
} }

View File

@ -30,8 +30,9 @@ namespace Ordering.API.Application.DomainEventHandlers.BuyerAndPaymentMethodVeri
orderToUpdate.SetBuyerId(buyerPaymentMethodVerifiedEvent.Buyer.Id); orderToUpdate.SetBuyerId(buyerPaymentMethodVerifiedEvent.Buyer.Id);
orderToUpdate.SetPaymentId(buyerPaymentMethodVerifiedEvent.Payment.Id); orderToUpdate.SetPaymentId(buyerPaymentMethodVerifiedEvent.Payment.Id);
_logger.CreateLogger(nameof(UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler)) _logger.CreateLogger<UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler>()
.LogTrace($"Order with Id: {buyerPaymentMethodVerifiedEvent.OrderId} has been successfully updated with a payment method id: { buyerPaymentMethodVerifiedEvent.Payment.Id }"); .LogTrace("Order with Id: {OrderId} has been successfully updated with a payment method {PaymentMethod} ({Id})",
buyerPaymentMethodVerifiedEvent.OrderId, nameof(buyerPaymentMethodVerifiedEvent.Payment), buyerPaymentMethodVerifiedEvent.Payment.Id);
} }
} }
} }

View File

@ -33,9 +33,9 @@ namespace Ordering.API.Application.DomainEventHandlers.OrderCancelled
public async Task Handle(OrderCancelledDomainEvent orderCancelledDomainEvent, CancellationToken cancellationToken) public async Task Handle(OrderCancelledDomainEvent orderCancelledDomainEvent, CancellationToken cancellationToken)
{ {
_logger.CreateLogger(nameof(OrderCancelledDomainEvent)) _logger.CreateLogger<OrderCancelledDomainEvent>()
.LogTrace($"Order with Id: {orderCancelledDomainEvent.Order.Id} has been successfully updated with " + .LogTrace("Order with Id: {OrderId} has been successfully updated to status {Status} ({Id})",
$"a status order id: {OrderStatus.Shipped.Id}"); orderCancelledDomainEvent.Order.Id, nameof(OrderStatus.Cancelled), OrderStatus.Cancelled.Id);
var order = await _orderRepository.GetAsync(orderCancelledDomainEvent.Order.Id); var order = await _orderRepository.GetAsync(orderCancelledDomainEvent.Order.Id);
var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString()); var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString());

View File

@ -33,9 +33,9 @@
public async Task Handle(OrderStatusChangedToAwaitingValidationDomainEvent orderStatusChangedToAwaitingValidationDomainEvent, CancellationToken cancellationToken) public async Task Handle(OrderStatusChangedToAwaitingValidationDomainEvent orderStatusChangedToAwaitingValidationDomainEvent, CancellationToken cancellationToken)
{ {
_logger.CreateLogger(nameof(OrderStatusChangedToAwaitingValidationDomainEvent)) _logger.CreateLogger<OrderStatusChangedToAwaitingValidationDomainEvent>()
.LogTrace($"Order with Id: {orderStatusChangedToAwaitingValidationDomainEvent.OrderId} has been successfully updated with " + .LogTrace("Order with Id: {OrderId} has been successfully updated to status {Status} ({Id})",
$"a status order id: {OrderStatus.AwaitingValidation.Id}"); orderStatusChangedToAwaitingValidationDomainEvent.OrderId, nameof(OrderStatus.AwaitingValidation), OrderStatus.AwaitingValidation.Id);
var order = await _orderRepository.GetAsync(orderStatusChangedToAwaitingValidationDomainEvent.OrderId); var order = await _orderRepository.GetAsync(orderStatusChangedToAwaitingValidationDomainEvent.OrderId);

View File

@ -35,9 +35,9 @@
public async Task Handle(OrderStatusChangedToPaidDomainEvent orderStatusChangedToPaidDomainEvent, CancellationToken cancellationToken) public async Task Handle(OrderStatusChangedToPaidDomainEvent orderStatusChangedToPaidDomainEvent, CancellationToken cancellationToken)
{ {
_logger.CreateLogger(nameof(OrderStatusChangedToPaidDomainEventHandler)) _logger.CreateLogger<OrderStatusChangedToPaidDomainEventHandler>()
.LogTrace($"Order with Id: {orderStatusChangedToPaidDomainEvent.OrderId} has been successfully updated with " + .LogTrace("Order with Id: {OrderId} has been successfully updated to status {Status} ({Id})",
$"a status order id: {OrderStatus.Paid.Id}"); orderStatusChangedToPaidDomainEvent.OrderId, nameof(OrderStatus.Paid), OrderStatus.Paid.Id);
var order = await _orderRepository.GetAsync(orderStatusChangedToPaidDomainEvent.OrderId); var order = await _orderRepository.GetAsync(orderStatusChangedToPaidDomainEvent.OrderId);
var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString()); var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString());

View File

@ -33,9 +33,9 @@ namespace Ordering.API.Application.DomainEventHandlers.OrderShipped
public async Task Handle(OrderShippedDomainEvent orderShippedDomainEvent, CancellationToken cancellationToken) public async Task Handle(OrderShippedDomainEvent orderShippedDomainEvent, CancellationToken cancellationToken)
{ {
_logger.CreateLogger(nameof(OrderShippedDomainEvent)) _logger.CreateLogger<OrderShippedDomainEvent>()
.LogTrace($"Order with Id: {orderShippedDomainEvent.Order.Id} has been successfully updated with " + .LogTrace("Order with Id: {OrderId} has been successfully updated to status {Status} ({Id})",
$"a status order id: {OrderStatus.Shipped.Id}"); orderShippedDomainEvent.Order.Id, nameof(OrderStatus.Shipped), OrderStatus.Shipped.Id);
var order = await _orderRepository.GetAsync(orderShippedDomainEvent.Order.Id); var order = await _orderRepository.GetAsync(orderShippedDomainEvent.Order.Id);
var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString()); var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString());

View File

@ -61,7 +61,9 @@ namespace Ordering.API.Application.DomainEventHandlers.OrderStartedEvent
var orderStatusChangedTosubmittedIntegrationEvent = new OrderStatusChangedToSubmittedIntegrationEvent(orderStartedEvent.Order.Id, orderStartedEvent.Order.OrderStatus.Name, buyer.Name); var orderStatusChangedTosubmittedIntegrationEvent = new OrderStatusChangedToSubmittedIntegrationEvent(orderStartedEvent.Order.Id, orderStartedEvent.Order.OrderStatus.Name, buyer.Name);
await _orderingIntegrationEventService.AddAndSaveEventAsync(orderStatusChangedTosubmittedIntegrationEvent); await _orderingIntegrationEventService.AddAndSaveEventAsync(orderStatusChangedTosubmittedIntegrationEvent);
_logger.CreateLogger(nameof(ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler)).LogTrace($"Buyer {buyerUpdated.Id} and related payment method were validated or updated for orderId: {orderStartedEvent.Order.Id}."); _logger.CreateLogger<ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler>()
.LogTrace("Buyer {BuyerId} and related payment method were validated or updated for orderId: {OrderId}.",
buyerUpdated.Id, orderStartedEvent.Order.Id);
} }
} }
} }

View File

@ -33,9 +33,9 @@
public async Task Handle(OrderStatusChangedToStockConfirmedDomainEvent orderStatusChangedToStockConfirmedDomainEvent, CancellationToken cancellationToken) public async Task Handle(OrderStatusChangedToStockConfirmedDomainEvent orderStatusChangedToStockConfirmedDomainEvent, CancellationToken cancellationToken)
{ {
_logger.CreateLogger(nameof(OrderStatusChangedToStockConfirmedDomainEventHandler)) _logger.CreateLogger<OrderStatusChangedToStockConfirmedDomainEventHandler>()
.LogTrace($"Order with Id: {orderStatusChangedToStockConfirmedDomainEvent.OrderId} has been successfully updated with " + .LogTrace("Order with Id: {OrderId} has been successfully updated to status {Status} ({Id})",
$"a status order id: {OrderStatus.StockConfirmed.Id}"); orderStatusChangedToStockConfirmedDomainEvent.OrderId, nameof(OrderStatus.StockConfirmed), OrderStatus.StockConfirmed.Id);
var order = await _orderRepository.GetAsync(orderStatusChangedToStockConfirmedDomainEvent.OrderId); var order = await _orderRepository.GetAsync(orderStatusChangedToStockConfirmedDomainEvent.OrderId);
var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString()); var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString());

View File

@ -74,7 +74,7 @@
} }
catch (Exception ex) catch (Exception ex)
{ {
log.LogError(ex.Message); log.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message);
return GetPredefinedCardTypes(); return GetPredefinedCardTypes();
} }
@ -82,7 +82,7 @@
return File.ReadAllLines(csvFileCardTypes) return File.ReadAllLines(csvFileCardTypes)
.Skip(1) // skip header column .Skip(1) // skip header column
.SelectTry(x => CreateCardType(x, ref id)) .SelectTry(x => CreateCardType(x, ref id))
.OnCaughtException(ex => { log.LogError(ex.Message); return null; }) .OnCaughtException(ex => { log.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); return null; })
.Where(x => x != null); .Where(x => x != null);
} }
@ -118,7 +118,7 @@
} }
catch (Exception ex) catch (Exception ex)
{ {
log.LogError(ex.Message); log.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message);
return GetPredefinedOrderStatus(); return GetPredefinedOrderStatus();
} }
@ -126,7 +126,7 @@
return File.ReadAllLines(csvFileOrderStatus) return File.ReadAllLines(csvFileOrderStatus)
.Skip(1) // skip header row .Skip(1) // skip header row
.SelectTry(x => CreateOrderStatus(x, ref id)) .SelectTry(x => CreateOrderStatus(x, ref id))
.OnCaughtException(ex => { log.LogError(ex.Message); return null; }) .OnCaughtException(ex => { log.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); return null; })
.Where(x => x != null); .Where(x => x != null);
} }
@ -182,7 +182,7 @@
sleepDurationProvider: retry => TimeSpan.FromSeconds(5), sleepDurationProvider: retry => TimeSpan.FromSeconds(5),
onRetry: (exception, timeSpan, retry, ctx) => onRetry: (exception, timeSpan, retry, ctx) =>
{ {
logger.LogTrace($"[{prefix}] Exception {exception.GetType().Name} with message ${exception.Message} detected on attempt {retry} of {retries}"); logger.LogWarning(exception, "[{prefix}] Exception {ExceptionType} with message {Message} detected on attempt {retry} of {retries}", prefix, exception.GetType().Name, exception.Message, retry, retries);
} }
); );
} }

View File

@ -80,7 +80,7 @@
var pathBase = Configuration["PATH_BASE"]; var pathBase = Configuration["PATH_BASE"];
if (!string.IsNullOrEmpty(pathBase)) if (!string.IsNullOrEmpty(pathBase))
{ {
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'"); loggerFactory.CreateLogger<Startup>().LogDebug("Using PATH BASE '{pathBase}'", pathBase);
app.UsePathBase(pathBase); app.UsePathBase(pathBase);
} }

View File

@ -33,27 +33,27 @@ namespace Ordering.BackgroundTasks.Tasks
protected override async Task ExecuteAsync(CancellationToken stoppingToken) protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{ {
_logger.LogDebug($"GracePeriodManagerService is starting."); _logger.LogDebug("GracePeriodManagerService is starting.");
stoppingToken.Register(() => _logger.LogDebug($"#1 GracePeriodManagerService background task is stopping.")); stoppingToken.Register(() => _logger.LogDebug("#1 GracePeriodManagerService background task is stopping."));
while (!stoppingToken.IsCancellationRequested) while (!stoppingToken.IsCancellationRequested)
{ {
_logger.LogDebug($"GracePeriodManagerService background task is doing background work."); _logger.LogDebug("GracePeriodManagerService background task is doing background work.");
CheckConfirmedGracePeriodOrders(); CheckConfirmedGracePeriodOrders();
await Task.Delay(_settings.CheckUpdateTime, stoppingToken); await Task.Delay(_settings.CheckUpdateTime, stoppingToken);
} }
_logger.LogDebug($"GracePeriodManagerService background task is stopping."); _logger.LogDebug("GracePeriodManagerService background task is stopping.");
await Task.CompletedTask; await Task.CompletedTask;
} }
private void CheckConfirmedGracePeriodOrders() private void CheckConfirmedGracePeriodOrders()
{ {
_logger.LogDebug($"Checking confirmed grace period orders"); _logger.LogDebug("Checking confirmed grace period orders");
var orderIds = GetConfirmedGracePeriodOrders(); var orderIds = GetConfirmedGracePeriodOrders();
@ -84,7 +84,7 @@ namespace Ordering.BackgroundTasks.Tasks
} }
catch (SqlException exception) catch (SqlException exception)
{ {
_logger.LogCritical($"FATAL ERROR: Database connections could not be opened: {exception.Message}"); _logger.LogCritical(exception, "FATAL ERROR: Database connections could not be opened: {Message}", exception.Message);
} }
} }

View File

@ -128,7 +128,7 @@ namespace Ordering.SignalrHub
var pathBase = Configuration["PATH_BASE"]; var pathBase = Configuration["PATH_BASE"];
if (!string.IsNullOrEmpty(pathBase)) if (!string.IsNullOrEmpty(pathBase))
{ {
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'"); loggerFactory.CreateLogger<Startup>().LogDebug("Using PATH BASE '{pathBase}'", pathBase);
app.UsePathBase(pathBase); app.UsePathBase(pathBase);
} }

View File

@ -15,7 +15,7 @@ namespace WebMVC.Infrastructure
{ {
public static void Seed(IApplicationBuilder applicationBuilder, IHostingEnvironment env, ILoggerFactory loggerFactory) public static void Seed(IApplicationBuilder applicationBuilder, IHostingEnvironment env, ILoggerFactory loggerFactory)
{ {
var log = loggerFactory.CreateLogger("WebMVC seed"); var log = loggerFactory.CreateLogger<WebContextSeed>();
var settings = (AppSettings)applicationBuilder var settings = (AppSettings)applicationBuilder
.ApplicationServices.GetRequiredService<IOptions<AppSettings>>().Value; .ApplicationServices.GetRequiredService<IOptions<AppSettings>>().Value;
@ -39,7 +39,7 @@ namespace WebMVC.Infrastructure
string overrideCssFile = Path.Combine(contentRootPath, "Setup", "override.css"); string overrideCssFile = Path.Combine(contentRootPath, "Setup", "override.css");
if (!File.Exists(overrideCssFile)) if (!File.Exists(overrideCssFile))
{ {
log.LogError($" override css file '{overrideCssFile}' does not exists."); log.LogError("Override css file '{FileName}' does not exists.", overrideCssFile);
return; return;
} }
@ -48,7 +48,7 @@ namespace WebMVC.Infrastructure
} }
catch (Exception ex) catch (Exception ex)
{ {
log.LogError($"Exception in method GetPreconfiguredCSS WebMVC. Exception Message={ex.Message}"); log.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message);
} }
} }
@ -59,7 +59,7 @@ namespace WebMVC.Infrastructure
string imagesZipFile = Path.Combine(contentRootPath, "Setup", "images.zip"); string imagesZipFile = Path.Combine(contentRootPath, "Setup", "images.zip");
if (!File.Exists(imagesZipFile)) if (!File.Exists(imagesZipFile))
{ {
log.LogError($" zip file '{imagesZipFile}' does not exists."); log.LogError("Zip file '{ZipFileName}' does not exists.", imagesZipFile);
return; return;
} }
@ -81,14 +81,14 @@ namespace WebMVC.Infrastructure
} }
else else
{ {
log.LogWarning($"Skip file '{entry.Name}' in zipfile '{imagesZipFile}'"); log.LogWarning("Skipped file '{FileName}' in zipfile '{ZipFileName}'", entry.Name, imagesZipFile);
} }
} }
} }
} }
catch ( Exception ex ) catch ( Exception ex )
{ {
log.LogError($"Exception in method GetPreconfiguredImages WebMVC. Exception Message={ex.Message}"); log.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message);
} }
} }

View File

@ -74,7 +74,7 @@ namespace Microsoft.eShopOnContainers.WebMVC
var pathBase = Configuration["PATH_BASE"]; var pathBase = Configuration["PATH_BASE"];
if (!string.IsNullOrEmpty(pathBase)) if (!string.IsNullOrEmpty(pathBase))
{ {
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'"); loggerFactory.CreateLogger<Startup>().LogDebug("Using PATH BASE '{PathBase}'", pathBase);
app.UsePathBase(pathBase); app.UsePathBase(pathBase);
} }
@ -93,8 +93,6 @@ namespace Microsoft.eShopOnContainers.WebMVC
app.UseAuthentication(); app.UseAuthentication();
var log = loggerFactory.CreateLogger("identity");
WebContextSeed.Seed(app, env, loggerFactory); WebContextSeed.Seed(app, env, loggerFactory);
app.UseHttpsRedirection(); app.UseHttpsRedirection();

View File

@ -51,7 +51,7 @@
{ {
retryForAvaiability++; retryForAvaiability++;
var log = loggerFactory.CreateLogger("catalog seed"); var log = loggerFactory.CreateLogger("catalog seed");
log.LogError(ex.Message); log.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message);
await SeedAsync(applicationBuilder, loggerFactory, retryForAvaiability); await SeedAsync(applicationBuilder, loggerFactory, retryForAvaiability);
} }
} }

View File

@ -15,7 +15,7 @@ namespace WebSPA.Infrastructure
{ {
public static void Seed(IApplicationBuilder applicationBuilder, IHostingEnvironment env, ILoggerFactory loggerFactory) public static void Seed(IApplicationBuilder applicationBuilder, IHostingEnvironment env, ILoggerFactory loggerFactory)
{ {
var log = loggerFactory.CreateLogger("WebSPA seed"); var log = loggerFactory.CreateLogger<WebContextSeed>();
var settings = (AppSettings)applicationBuilder var settings = (AppSettings)applicationBuilder
.ApplicationServices.GetRequiredService<IOptions<AppSettings>>().Value; .ApplicationServices.GetRequiredService<IOptions<AppSettings>>().Value;
@ -37,7 +37,7 @@ namespace WebSPA.Infrastructure
string imagesZipFile = Path.Combine(contentRootPath, "Setup", "images.zip"); string imagesZipFile = Path.Combine(contentRootPath, "Setup", "images.zip");
if (!File.Exists(imagesZipFile)) if (!File.Exists(imagesZipFile))
{ {
log.LogError($" zip file '{imagesZipFile}' does not exists."); log.LogError("Zip file '{ZipFileName}' does not exists.", imagesZipFile);
return; return;
} }
@ -59,14 +59,14 @@ namespace WebSPA.Infrastructure
} }
else else
{ {
log.LogWarning($"Skip file '{entry.Name}' in zipfile '{imagesZipFile}'"); log.LogWarning("Skipped file '{FileName}' in zipfile '{ZipFileName}'", entry.Name, imagesZipFile);
} }
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
log.LogError($"Exception in method GetPreconfiguredImages WebSPA. Exception Message={ex.Message}"); log.LogError(ex, "ERROR in GetPreconfiguredImages: {Message}", ex.Message);
} }
} }
} }

View File

@ -118,7 +118,7 @@ namespace eShopConContainers.WebSPA
var pathBase = Configuration["PATH_BASE"]; var pathBase = Configuration["PATH_BASE"];
if (!string.IsNullOrEmpty(pathBase)) if (!string.IsNullOrEmpty(pathBase))
{ {
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'"); loggerFactory.CreateLogger<Startup>().LogDebug("Using PATH BASE '{pathBase}'", pathBase);
app.UsePathBase(pathBase); app.UsePathBase(pathBase);
} }