Cleans up static loggers

Adds test projects for different frameworks and architectures
Adds registration tool assembly
This commit is contained in:
Ryan Newington
2023-01-29 17:30:37 +11:00
parent 4366b24e63
commit 1205f217b3
46 changed files with 1589 additions and 200 deletions
@@ -0,0 +1,36 @@
using Microsoft.Extensions.Logging;
using NLog;
using NLog.Extensions.Logging;
namespace Lithnet.CredentialProvider.Samples
{
internal static class InternalLogger
{
internal static ILoggerFactory LoggerFactory { get; }
static InternalLogger()
{
/*
This sample uses NLog to capture trace events from the provider, but you can use any
logging system compatible with Microsoft.Extensions.Logging;
*/
var config = new NLog.Config.LoggingConfiguration();
var logconsole = new NLog.Targets.ConsoleTarget("logconsole");
/*
Add file based logging if required
*/
var logfile = new NLog.Targets.FileTarget("logfile") { FileName = "c:\\file.txt" };
config.AddRule(NLog.LogLevel.Trace, NLog.LogLevel.Fatal, logfile);
config.AddRule(NLog.LogLevel.Trace, NLog.LogLevel.Fatal, logconsole);
LogManager.Configuration = config;
InternalLogger.LoggerFactory = new NLogLoggerFactory(new NLogLoggerProvider(new NLogProviderOptions() { ReplaceLoggerFactory = true }, LogManager.LogFactory));
}
}
}