/// <summary> /// Instantiate a new instance and allocate and initialize class resources. /// </summary> static LogManager() { CompleteMessageProcessing = true; s_LogChannels = new ConcurrentQueue <ILogChannel>(); s_MessageQuque = new BlockingCollection <LogMessage>(); s_ProcessName = Process.GetCurrentProcess().ProcessName; AppDomain.CurrentDomain.ProcessExit += OnExit; //add internal loger channel s_InternalLogger = new FileChannel(); DataStore internalLoggerSettings = new DataStore(); internalLoggerSettings.Create <string>("FileName", Path.ChangeExtension(Path.GetFileName(Environment.GetCommandLineArgs().First()), "log")); s_InternalLogger.Initialize(internalLoggerSettings); LogSettings settings = ConfigManager.LoadSection <LogSettings>(); //configure the log channels if (settings != null) { MethodInfo addChannelMethod = typeof(LogManager).GetMethod("AddChannel", BindingFlags.Static | BindingFlags.Public); foreach (KeyValuePair <string, DataStore> chSetings in settings.ChannelSettings) { //create a new instance of the channel PluginFactory <ILogChannel> channelFactory = PluginLoader.GetFactories <ILogChannel, ILogChannelMetaData>(ch => ch.Name == chSetings.Key).FirstOrDefault(); if (channelFactory != null) { addChannelMethod.MakeGenericMethod(channelFactory.PluginType).Invoke(null, new[] { chSetings.Value }); } else { LogInternally(string.Format("Channel class {0} was not found.", chSetings.Key)); } } } else { LogInternally("No logger configuration found"); } }