| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using System;
- using Microsoft.Extensions.Logging;
- using NLog;
- using NLog.Config;
- using Quadarax.Foundation.Core.Logging;
- using Quadarax.Foundation.Core.Object;
- using ILogger = Quadarax.Foundation.Core.Logging.ILogger;
- using LogLevel = Microsoft.Extensions.Logging.LogLevel;
- namespace Quadarax.Foundation.Core.NLog
- {
- public class LoggerFactory : Singleton<ILogger, LoggerFactory>, ILogger
- {
- public static string ConfigurationFileName { get; set; }
- public void Configure(string configurationFileName)
- {
- if (!string.IsNullOrEmpty(configurationFileName))
- {
- LogManager.Configuration = new XmlLoggingConfiguration(configurationFileName);
- var log = Instance.GetLogger(GetType());
- log.Log(LogSeverityEnum.Debug, $"NLOG initialized from configuration file '{configurationFileName}'");
- }
- }
- public ILog GetLogger(string loggerName)
- {
- return Instance.GetLogger(loggerName);
- }
- public ILog GetLogger(Type loggerForType)
- {
- return Instance.GetLogger(loggerForType);
- }
- ILog ILogger.GetLogger(string loggerName)
- {
- return new Logger(loggerName);
- }
- ILog ILogger.GetLogger(Type loggerForType)
- {
- return new Logger(loggerForType);
- }
- public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
- {
- throw new NotImplementedException();
- }
- public bool IsEnabled(LogLevel logLevel)
- {
- throw new NotImplementedException();
- }
- public IDisposable BeginScope<TState>(TState state) where TState : notnull
- {
- throw new NotImplementedException();
- }
- }
- }
|