币安量化交易
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.0 KiB

using NLog;
using System.Collections.Generic;
namespace Binance.TradeRobot.Business
{
public class NLogManager
{
private IDictionary<string, ILogger> loggerDictionary = new Dictionary<string, ILogger>();
private string defaultLoggerName = "default";
public NLogManager()
{
loggerDictionary = new Dictionary<string, ILogger>()
{
{ "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;
}
}
}