Cleans up static loggers
Adds test projects for different frameworks and architectures Adds registration tool assembly
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user