last ...
This commit is contained in:
@@ -1,16 +1,16 @@
|
|||||||
|
using System;
|
||||||
using xCommons.Extensions;
|
using xCommons.Extensions;
|
||||||
using xExceptions.Constants;
|
using xExceptions.Constants;
|
||||||
using xLoggingService.Writers;
|
using xLoggingService.Writers;
|
||||||
using xEventService.Interfaces;
|
using xEventService.Interfaces;
|
||||||
using xLoggingService.Providers;
|
using xLoggingService.Providers;
|
||||||
using System.Collections.Generic;
|
using xLoggingService.Constants;
|
||||||
using xLoggingService.Interfaces;
|
using xLoggingService.Interfaces;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using xLoggingService.Configuration;
|
using xLoggingService.Configuration;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
using xLoggingService.Constants;
|
|
||||||
|
|
||||||
namespace xLoggingService.DI
|
namespace xLoggingService.DI
|
||||||
{
|
{
|
||||||
@@ -112,6 +112,12 @@ namespace xLoggingService.DI
|
|||||||
Console.WriteLine($"{XLogTag} => {message}");
|
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(
|
private static void AddLoggingService(
|
||||||
this IServiceCollection services,
|
this IServiceCollection services,
|
||||||
XLoggingServiceConfiguration configuration,
|
XLoggingServiceConfiguration configuration,
|
||||||
@@ -126,11 +132,62 @@ namespace xLoggingService.DI
|
|||||||
Log($"Invalid Service Lifetime ...");
|
Log($"Invalid Service Lifetime ...");
|
||||||
XException.InvalidArgs.Throw();
|
XException.InvalidArgs.Throw();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Register Service Configuration ...
|
// Register Service Configuration ...
|
||||||
services.AddXLoggingServiceConfiguration(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
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,7 @@
|
|||||||
|
|
||||||
<!-- Icon Handling -->
|
<!-- Icon Handling -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="../../Documents/Resources/Images/favicon.png" Link="icon.png" Pack="true"
|
<None Include="../../Documents/Resources/Images/favicon.png" Link="icon.png" Pack="true" PackagePath="\icon.png" />
|
||||||
PackagePath="\icon.png" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Local Modules -->
|
<!-- Local Modules -->
|
||||||
@@ -37,6 +36,7 @@
|
|||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="5.0.0" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.20.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- For XML Documentation Support -->
|
<!-- For XML Documentation Support -->
|
||||||
|
|||||||
Reference in New Issue
Block a user