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 { /// /// OCPP log factory /// public class OCPPLogFactory : LogFactoryBase { public OCPPLogFactory() : this("NLog.config") { } public OCPPLogFactory(string log4netConfig) : base(log4netConfig) { List configlist = new List(); configlist.Add(ConfigFile); NLog.Config.XmlLoggingConfiguration.SetCandidateConfigFilePaths(configlist); } /// /// Gets the config file file path. /// //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 configlist = new List(); // configlist.Add(ConfigFile); // NLog.Config.XmlLoggingConfiguration.SetCandidateConfigFilePaths(configlist); // return; // } //} /// /// Gets the log by name. /// /// The name. /// /// /// Gets the log by name. /// /// The name. /// /// //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); } } }