diff --git a/DI/XDIHelperExtension.cs b/DI/XDIHelperExtension.cs
index 82c0721..17abc28 100644
--- a/DI/XDIHelperExtension.cs
+++ b/DI/XDIHelperExtension.cs
@@ -1,16 +1,16 @@
+using System;
using xCommons.Extensions;
using xExceptions.Constants;
using xLoggingService.Writers;
using xEventService.Interfaces;
using xLoggingService.Providers;
-using System.Collections.Generic;
+using xLoggingService.Constants;
using xLoggingService.Interfaces;
using Microsoft.Extensions.Logging;
using xLoggingService.Configuration;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
-using System;
-using xLoggingService.Constants;
+using Microsoft.Extensions.DependencyInjection.Extensions;
namespace xLoggingService.DI
{
@@ -112,6 +112,12 @@ namespace xLoggingService.DI
Console.WriteLine($"{XLogTag} => {message}");
}
+ ///
+ /// Register Logging Service ...
+ ///
+ ///
+ ///
+ ///
private static void AddLoggingService(
this IServiceCollection services,
XLoggingServiceConfiguration configuration,
@@ -126,11 +132,62 @@ namespace xLoggingService.DI
Log($"Invalid Service Lifetime ...");
XException.InvalidArgs.Throw();
}
+
//
// Register Service Configuration ...
services.AddXLoggingServiceConfiguration(configuration);
//
+ // File Log Provider ...
+ if (configuration.File.Enabled)
+ {
+ //
+ services.TryAddEnumerable(
+ ServiceDescriptor.Singleton());
+
+ //
+ Log("FileLogWriter registered.");
+ }
+
+ //
+ // Database Log Provider ...
+ if (configuration.Database.Enabled)
+ {
+ //
+ services.TryAddEnumerable(
+ ServiceDescriptor.Singleton());
+
+ //
+ Log("DatabaseLogWriter registered.");
+ }
+
+ //
+ // Event Service Provider ...
+ if (configuration.Event.Enabled)
+ {
+ //
+ var eventService = services.GetRegisteredService();
+ if (eventService.IsNull())
+ {
+ //
+ Log("Event Service not Provided ...");
+ XException.InvalidConfiguration.Throw();
+ }
+
+ //
+ services.TryAddEnumerable(
+ ServiceDescriptor.Singleton());
+
+ //
+ Log("EventLogWriter registered.");
+ }
+
+ //
+ services.TryAddEnumerable(
+ ServiceDescriptor.Singleton());
+
+ //
+ Log($"Logging Service registered successfully ...");
}
#endregion
}
diff --git a/xLoggingService.csproj b/xLoggingService.csproj
index 1daa327..0dc6dfe 100644
--- a/xLoggingService.csproj
+++ b/xLoggingService.csproj
@@ -19,8 +19,7 @@
-
+
@@ -37,6 +36,7 @@
+