last ...
This commit is contained in:
@@ -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}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register Logging Service ...
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <param name="configuration"></param>
|
||||
/// <param name="lifeTime"></param>
|
||||
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<IXLogWriter, XFileLogWriter>());
|
||||
|
||||
//
|
||||
Log("FileLogWriter registered.");
|
||||
}
|
||||
|
||||
//
|
||||
// Database Log Provider ...
|
||||
if (configuration.Database.Enabled)
|
||||
{
|
||||
//
|
||||
services.TryAddEnumerable(
|
||||
ServiceDescriptor.Singleton<IXLogWriter, XDatabaseLogWriter>());
|
||||
|
||||
//
|
||||
Log("DatabaseLogWriter registered.");
|
||||
}
|
||||
|
||||
//
|
||||
// Event Service Provider ...
|
||||
if (configuration.Event.Enabled)
|
||||
{
|
||||
//
|
||||
var eventService = services.GetRegisteredService<IXEventServiceProvider>();
|
||||
if (eventService.IsNull())
|
||||
{
|
||||
//
|
||||
Log("Event Service not Provided ...");
|
||||
XException.InvalidConfiguration.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
services.TryAddEnumerable(
|
||||
ServiceDescriptor.Singleton<IXLogWriter, XEventLogWriter>());
|
||||
|
||||
//
|
||||
Log("EventLogWriter registered.");
|
||||
}
|
||||
|
||||
//
|
||||
services.TryAddEnumerable(
|
||||
ServiceDescriptor.Singleton<ILoggerProvider, XLoggerProvider>());
|
||||
|
||||
//
|
||||
Log($"Logging Service registered successfully ...");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user