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 { 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); } } }