| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System;
- using NLog;
- using NLog.Config;
- using Quadarax.Foundation.Core.Logging;
- using Quadarax.Foundation.Core.Object;
- using ILogger = Quadarax.Foundation.Core.Logging.ILogger;
- namespace Quadarax.Foundation.Core.NLog
- {
- public class LoggerFactory : Singleton<ILogger, LoggerFactory>, ILogger
- {
- public static string ConfigurationFileName { get; set; } = String.Empty;
- 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);
- }
- }
- }
|