Skip to content

Commit

Permalink
Added dynamic configuration of loggerfactory
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisDyallo committed Aug 8, 2024
1 parent e806738 commit a75c68e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Yubico.Core/src/Yubico/Core/Logging/Loggers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
namespace Yubico.Core.Logging
{
/// <summary>
/// TODO
/// TODO write
/// </summary>
public static class Loggers
{
private static readonly ILoggerFactory LoggerFactory = GetFactory();
private static ILoggerFactory GetFactory()
private static ILoggerFactory LoggerFactory = GetDefaultFactory();

private static ILoggerFactory GetDefaultFactory()
{
const string AppsettingsJson = "appsettings.json";
IConfigurationRoot configuration = new ConfigurationBuilder()
Expand All @@ -50,6 +51,13 @@ private static ILoggerFactory GetFactory()
});
}

/// <summary>
/// TODO write
/// </summary>
/// <param name="configure"></param>
public static void ConfigureLoggerFactory(Action<ILoggingBuilder> configure)
=> LoggerFactory = Microsoft.Extensions.Logging.LoggerFactory.Create(configure);

/// <inheritdoc cref="LoggerFactoryExtensions.CreateLogger{T}"/>
public static ILogger GetLogger<T>() => LoggerFactory.CreateLogger<T>();

Expand Down

0 comments on commit a75c68e

Please sign in to comment.