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
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
|
||||
<!-- Icon Handling -->
|
||||
<ItemGroup>
|
||||
<None Include="../../Documents/Resources/Images/favicon.png" Link="icon.png" Pack="true"
|
||||
PackagePath="\icon.png" />
|
||||
<None Include="../../Documents/Resources/Images/favicon.png" Link="icon.png" Pack="true" PackagePath="\icon.png" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Local Modules -->
|
||||
@@ -37,6 +36,7 @@
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="5.0.0" />
|
||||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.20.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- For XML Documentation Support -->
|
||||
|
||||
Reference in New Issue
Block a user