public LogManager(ServerCore parent, FileInfo configFile) { this._logs = new Dictionary<String, Log>(); this.Parent = parent; XmlConfigurator.ConfigureAndWatch(configFile); this._repository = log4net.LogManager.GetRepository(); }
/// <summary> /// MetaTweet サーバを初期化します。 /// </summary> /// <param name="host">初期化されるサーバ オブジェクト。</param> /// <param name="args">サーバ オブジェクトに渡された引数。</param> public static void Initialize(ServerCore host, IDictionary<String, String> args) { _host = host; InitializeHooksInObject(_host); InitializeHooksInObject(_host.ModuleManager); _host.ModuleManager.LoadHook.Succeeded.Add((manager, domainKey, ret) => { ModuleDomain dom = (ModuleDomain) ret; InitializeHooksInObject(dom); manager.Log.Info(Resources.ModuleAssemblyLoaded, domainKey); dom.AddHook.Succeeded.AddRange( (domain, moduleKey, typeName, options, configFile, module) => manager.Log.Info( Resources.ModuleObjectAdded, domainKey, moduleKey, typeName ), (domain, moduleKey, typeName, options, configFile, module) => RegisterModuleHook(module), (domain, moduleKey, typeName, options, configFile, module) => module.Configure(XmlConfiguration.Load(configFile)), (domain, moduleKey, typeName, options, configFile, module) => module.Initialize() ); dom.RemoveHook.Succeeded.Add((domain, moduleKey, type) => manager.Log.Info(Resources.ModuleObjectRemoved, domainKey, type.FullName, moduleKey) ); }); _host.ModuleManager.UnloadHook.Succeeded.Add((self, domain) => self.Log.Info(Resources.ModuleAssemblyUnloaded, domain) ); _host.RequestManager.RegisterHook.Succeeded.AddRange( (manager, req, task) => task.ProcessHook.Before.Add((self, type) => self.Parent.Log.Info(String.Format( Resources.ServerRequestExecuting, req ))), (manager, req, task) => task.ProcessHook.Succeeded.Add((self, type, ret) => self.Parent.Log.Info(String.Format( Resources.ServerRequestExecuted, req, self.ElapsedTime ))), (manager, req, task) => task.ProcessHook.Failed.Add((self, type, ex) => self.Parent.Log.Fatal(String.Format( Resources.ServerRequestExecuted, req, self.ElapsedTime ), ex)) ); InitializeHooksInObject(_host.RequestManager); host.ModuleManager.Configuration.ResolveChild("init").Values.ForEach(entry => { host.ModuleManager.Load(entry.Key); entry.Get<IList<ModuleObjectSetup>>() .ForEach(e => host.ModuleManager[entry.Key].Add(e)); }); }
public Log(ServerCore parent, FileInfo configFile) { this.Parent = parent; this._logger = LogManager.GetLogger(typeof(ServerCore)).Logger; XmlConfigurator.ConfigureAndWatch(this._logger.Repository, configFile); LevelMap map = this._logger.Repository.LevelMap; this._levelEmergency = map.LookupWithDefault(Level.Emergency); this._levelFatal = map.LookupWithDefault(Level.Fatal); this._levelAlert = map.LookupWithDefault(Level.Alert); this._levelCritical = map.LookupWithDefault(Level.Critical); this._levelSevere = map.LookupWithDefault(Level.Severe); this._levelError = map.LookupWithDefault(Level.Error); this._levelWarn = map.LookupWithDefault(Level.Warn); this._levelNotice = map.LookupWithDefault(Level.Notice); this._levelInfo = map.LookupWithDefault(Level.Info); this._levelDebug = map.LookupWithDefault(Level.Debug); this._levelTrace = map.LookupWithDefault(Level.Trace); this._levelVerbose = map.LookupWithDefault(Level.Verbose); }