fix Log Init

This commit is contained in:
Aigio Liu
2022-07-26 19:30:02 +08:00
parent 2a196b1ca0
commit 295948816b
3 changed files with 8 additions and 1 deletions
+5 -1
View File
@@ -11,7 +11,11 @@ namespace System;
/// </summary>
public static class Log
{
internal static ILoggerFactory Factory => DI.Get<ILoggerFactory>();
public static Func<ILoggerFactory>? LoggerFactory { private get; set; }
static ILoggerFactory? factory;
public static ILoggerFactory Factory => factory ??= DI.Get_Nullable<ILoggerFactory>() ?? LoggerFactory?.Invoke() ?? throw new ArgumentNullException(nameof(LoggerFactory));
public static ILogger CreateLogger(string tag) => Factory.CreateLogger(tag);
@@ -77,6 +77,7 @@ namespace System.Application.UI
// Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux)
PlatformApp?.Dispose();
DI.Dispose();
LogManager.Shutdown();
}
}
+2
View File
@@ -248,6 +248,8 @@ namespace System.Application.UI
}
config.LoggingRules.Add(new LoggingRule("*", minLevel, target));
}
Log.LoggerFactory = () => new LoggerFactory(new[] { new NLogLoggerProvider() });
}
#endregion