using NLog; using System.Collections.Generic; namespace Binance.TradeRobot.Business { public class NLogManager { private IDictionary loggerDictionary = new Dictionary(); private string defaultLoggerName = "default"; public NLogManager() { loggerDictionary = new Dictionary() { { "default",NLog.LogManager.GetLogger(defaultLoggerName)} }; } public ILogger Default() { return loggerDictionary[defaultLoggerName]; } public ILogger GetLogger(string loggerName) { if (string.IsNullOrEmpty(loggerName)) return Default(); if (!loggerDictionary.TryGetValue(loggerName, out ILogger logger)) { logger = NLog.LogManager.GetLogger(loggerName); loggerDictionary.TryAdd(loggerName, logger); } return logger; } } }