diff --git a/Directory.Packages.props b/Directory.Packages.props
index 5f39dc3..932669e 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -3,9 +3,9 @@
true
-
-
-
+
+
+
@@ -16,24 +16,24 @@
-
+
-
+
-
-
-
-
-
+
+
+
+
+
-
+
@@ -54,8 +54,8 @@
-
-
+
+
\ No newline at end of file
diff --git a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoProxy.cs b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoProxy.cs
index 4811d63..ed02816 100644
--- a/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoProxy.cs
+++ b/MessagingService.BusinessLogic/Services/EmailServices/Smtp2Go/Smtp2GoProxy.cs
@@ -74,7 +74,7 @@ public async Task SendEmail(Guid messageId,
String requestSerialised = StringSerialiser.Serialise(apiRequest, new SerialiserOptions(SerialiserPropertyFormat.SnakeCase, WriteIndented:true));
- Logger.LogDebug($"Request Message Sent to Email Provider [SMTP2Go] {requestSerialised}");
+ Logger.LogDebug("Request Message Sent to Email Provider [SMTP2Go] {apiRequest}", requestSerialised);
StringContent content = new(requestSerialised, Encoding.UTF8, "application/json");
@@ -89,7 +89,7 @@ public async Task SendEmail(Guid messageId,
_ => new Smtp2GoSendEmailResponse { Data = new Smtp2GoSendEmailResponseData { Error = httpResponse.StatusCode.ToString(), ErrorCode = ((Int32)httpResponse.StatusCode).ToString() } }
};
- Logger.LogDebug($"Response Message Received from Email Provider [SMTP2Go] {StringSerialiser.Serialise(apiResponse)}");
+ Logger.LogDebug("Response Message Received from Email Provider [SMTP2Go] {apiResponse}", StringSerialiser.Serialise(apiResponse));
// Translate the Response
return new EmailServiceProxyResponse {
ApiCallSuccessful = httpResponse.IsSuccessStatusCode && String.IsNullOrEmpty(apiResponse.Data.ErrorCode),
@@ -119,7 +119,7 @@ public async Task GetMessageStatus(String providerReferen
String requestSerialised = StringSerialiser.Serialise(apiRequest, new SerialiserOptions(SerialiserPropertyFormat.SnakeCase, WriteIndented: true));
- Logger.LogDebug($"Request Message Sent to Email Provider [SMTP2Go] {requestSerialised}");
+ Logger.LogDebug("Request Message Sent to Email Provider [SMTP2Go] {apiRequest}", requestSerialised);
StringContent content = new(requestSerialised, Encoding.UTF8, "application/json");
@@ -131,7 +131,7 @@ public async Task GetMessageStatus(String providerReferen
Smtp2GoEmailSearchResponse apiResponse = StringSerialiser.Deserialise(await httpResponse.Content.ReadAsStringAsync(cancellationToken));
- Logger.LogDebug($"Response Message Received from Email Provider [SMTP2Go] {StringSerialiser.Serialise(apiResponse)}");
+ Logger.LogDebug("Response Message Received from Email Provider [SMTP2Go] {apiResponse}", StringSerialiser.Serialise(apiResponse));
// Translate the Response
return new MessageStatusResponse { ApiStatusCode = httpResponse.StatusCode, MessageStatus = this.TranslateMessageStatus(apiResponse.Data.EmailDetails.Single().Status), ProviderStatusDescription = apiResponse.Data.EmailDetails.Single().Status, Timestamp = apiResponse.Data.EmailDetails.Single().EmailStatusDate };
diff --git a/MessagingService.IntegrationTests/Common/GenericSteps.cs b/MessagingService.IntegrationTests/Common/GenericSteps.cs
index abb003c..bc38689 100644
--- a/MessagingService.IntegrationTests/Common/GenericSteps.cs
+++ b/MessagingService.IntegrationTests/Common/GenericSteps.cs
@@ -2,8 +2,6 @@
using Shared.IntegrationTesting;
using Shared.Logger;
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Threading.Tasks;
namespace MessagingService.IntegrationTests.Common
@@ -31,10 +29,11 @@ public async Task StartSystem()
{
// Initialise a logger
- String scenarioName = this.ScenarioContext.ScenarioInfo.Title.Replace(" ", "");
+ String scenarioName = this.ScenarioContext.ScenarioInfo.Title.Replace(" ", String.Empty);
NlogLogger logger = new();
logger.Initialise(LogManager.GetLogger(scenarioName), scenarioName);
- LogManager.AddHiddenAssembly(typeof(NlogLogger).Assembly);
+ LogManager.Setup().SetupLogFactory(setup =>
+ setup.AddCallSiteHiddenAssembly(typeof(NlogLogger).Assembly));
DockerServices dockerServices = DockerServices.SqlServer | DockerServices.MessagingService | DockerServices.KurrentDb | DockerServices.SecurityService;
diff --git a/MessagingService/Bootstrapper/MediatorRegistry.cs b/MessagingService/Bootstrapper/MediatorRegistry.cs
index 6696e16..50f996e 100644
--- a/MessagingService/Bootstrapper/MediatorRegistry.cs
+++ b/MessagingService/Bootstrapper/MediatorRegistry.cs
@@ -1,13 +1,7 @@
-using MessagingService.DataTransferObjects;
-using SimpleResults;
-
-namespace MessagingService.Bootstrapper;
+namespace MessagingService.Bootstrapper;
using BusinessLogic.RequestHandlers;
-using BusinessLogic.Requests;
-using Google.Api;
using Lamar;
-using MediatR;
using Microsoft.Extensions.DependencyInjection;
using Shared.General;
using System;
@@ -18,7 +12,10 @@ public class MediatorRegistry : ServiceRegistry
{
public MediatorRegistry()
{
- this.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(MessagingRequestHandler).Assembly));
+ this.AddMediatR(cfg => {
+ cfg.RegisterServicesFromAssembly(typeof(MessagingRequestHandler).Assembly);
+ cfg.LicenseKey = Environment.GetEnvironmentVariable("MEDIATR_LICENCEKEY");
+ });
this.AddSingleton>(container => (serviceName) => ConfigurationReader.GetBaseServerUri(serviceName).OriginalString);
}
}
\ No newline at end of file
diff --git a/MessagingService/Common/Extensions.cs b/MessagingService/Common/Extensions.cs
index 562541c..94b6f88 100644
--- a/MessagingService/Common/Extensions.cs
+++ b/MessagingService/Common/Extensions.cs
@@ -28,10 +28,10 @@ public static class Extensions
switch (tt)
{
case TraceEventType.Critical:
- Logger.LogCritical(new Exception(logMessage));
+ Logger.LogCritical(logMessage);
break;
case TraceEventType.Error:
- Logger.LogError(new Exception(logMessage));
+ Logger.LogError(logMessage);
break;
case TraceEventType.Warning:
Logger.LogWarning(logMessage);
diff --git a/MessagingService/Handlers/DomainEventHandlers.cs b/MessagingService/Handlers/DomainEventHandlers.cs
index 73a90b1..964ec2b 100644
--- a/MessagingService/Handlers/DomainEventHandlers.cs
+++ b/MessagingService/Handlers/DomainEventHandlers.cs
@@ -28,13 +28,13 @@ public static async Task HandleDomainEvent(HttpRequest request,
try
{
- Logger.LogInformation($"Processing event - ID [{domainEvent.EventId}], Type[{domainEvent.GetType().Name}]");
+ Logger.LogInformation("Processing event - ID [{eventId}], Type[{eventType}]", domainEvent.EventId, domainEvent.GetType().Name);
Result> eventHandlersResult = resolver.GetDomainEventHandlers(domainEvent);
if (eventHandlersResult.IsFailed)
{
- Logger.LogWarning($"No event handlers configured for Event Type [{domainEvent.GetType().Name}]");
+ Logger.LogWarning("No event handlers configured for Event Type [{eventType}]", domainEvent.GetType().Name);
return Results.Ok();
}
@@ -42,14 +42,14 @@ public static async Task HandleDomainEvent(HttpRequest request,
var tasks = eventHandlers.Select(h => h.Handle(domainEvent, cancellationToken));
await Task.WhenAll(tasks);
- Logger.LogInformation("Finished processing event - ID [{domainEvent.EventId}]");
+ Logger.LogInformation("Finished processing event - ID [{eventId}]", domainEvent.EventId);
return Results.Ok();
}
catch (Exception ex)
{
string domainEventData = StringSerialiser.Serialise(domainEvent);
- Logger.LogError($"Failed to process event. Data received [{domainEventData}]", ex);
+ Logger.LogError(ex, "Failed to process event. Data received [{domainEventData}]", domainEventData);
throw;
}
}
@@ -58,7 +58,7 @@ private static void Callback(CancellationToken cancellationToken, Guid eventId)
{
if (cancellationToken.IsCancellationRequested)
{
- Logger.LogInformation($"Cancel request for EventId {eventId}");
+ Logger.LogInformation("Cancel request for EventId {eventId}", eventId);
cancellationToken.ThrowIfCancellationRequested();
}
}
diff --git a/MessagingService/Program.cs b/MessagingService/Program.cs
index a0da357..3797d78 100644
--- a/MessagingService/Program.cs
+++ b/MessagingService/Program.cs
@@ -149,8 +149,8 @@ private static void ConfigureApplication(WebApplication app)
app.UseDeveloperExceptionPage();
}
- Microsoft.Extensions.Logging.ILogger logger = app.Services.GetRequiredService().CreateLogger("MessagingService");
- Shared.Logger.Logger.Initialise(logger);
+ NLog.Logger logger = LogManager.GetLogger("MessagingService");
+ Shared.Logger.Logger.Initialise(logger, "messagingservice");
((IConfigurationRoot)app.Configuration).LogConfiguration(Shared.Logger.Logger.LogWarning);
IStringSerialiser serialiser = app.Services.GetRequiredService();
diff --git a/MessagingService/nlog.config b/MessagingService/nlog.config
index 269162a..5097b83 100644
--- a/MessagingService/nlog.config
+++ b/MessagingService/nlog.config
@@ -2,24 +2,24 @@
-
-
-
+
+
+
+
+
+
+
+
+