123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
-
- using SuperSocket.SocketBase;
- using SuperSocket.SocketBase.Logging;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace OCPPServer.SubProtocol
- {
- /// <summary>
- /// OCPP log factory
- /// </summary>
- public class OCPPLogFactory : LogFactoryBase
- {
- public OCPPLogFactory()
- : this("NLog.config")
- {
- }
- public OCPPLogFactory(string log4netConfig)
- : base(log4netConfig)
- {
- List<string> configlist = new List<string>();
- configlist.Add(ConfigFile);
- NLog.Config.XmlLoggingConfiguration.SetCandidateConfigFilePaths(configlist);
- }
- /// <summary>
- /// Gets the config file file path.
- /// </summary>
- //protected string ConfigFile { get; private set; }
- //public OCPPLogFactory()
- //{
- // string configFile = "NLog.config";
- // var currentAppDomain = AppDomain.CurrentDomain;
- // var isolation = IsolationMode.None;
- // var isolationValue = currentAppDomain.GetData(typeof(IsolationMode).Name);
- // if (isolationValue != null)
- // isolation = (IsolationMode)isolationValue;
- // if (isolation == IsolationMode.None)
- // {
- // var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, configFile);
- // if (File.Exists(filePath))
- // {
- // ConfigFile = filePath;
- // return;
- // }
- // filePath = Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config"), configFile);
- // if (File.Exists(filePath))
- // {
- // ConfigFile = filePath;
- // return;
- // }
- // ConfigFile = configFile;
- // List<string> configlist = new List<string>();
- // configlist.Add(ConfigFile);
- // NLog.Config.XmlLoggingConfiguration.SetCandidateConfigFilePaths(configlist);
- // return;
- // }
- //}
- /// <summary>
- /// Gets the log by name.
- /// </summary>
- /// <param name="name">The name.</param>
- /// <returns></returns>
- /// <summary>
- /// Gets the log by name.
- /// </summary>
- /// <param name="name">The name.</param>
- /// <returns></returns>
- ///
- //public override ILog GetLog(string name)
- //{
- // NLog.ILogger logger = NLog.LogManager.GetCurrentClassLogger();
- // //return new ConsoleLog(name);
- // ILog log = logger as Log4NetLog;
- // return new Log4NetLog(LogManager.GetLogger(name)); ;
- //}
- public override SuperSocket.SocketBase.Logging.ILog GetLog(string name)
- {
-
- return new OCPPLog(name);
- }
- }
- }
|