public void RegisterCommonAppenders(IConfig startupConfig) { ILoggerRepository repository = LogManager.GetRepository(); IAppender[] appenders = repository.GetAppenders(); foreach (IAppender appender in appenders) { if (appender.Name == "Console") { m_consoleAppender = (OpenSimAppender)appender; } else if (appender.Name == "LogFileAppender") { m_logFileAppender = (FileAppender)appender; } } if (null == m_consoleAppender) { Notice("No appender named Console found (see the log4net config file for this executable)!"); } else { // FIXME: This should be done through an interface rather than casting. m_consoleAppender.Console = (ConsoleBase)m_console; // If there is no threshold set then the threshold is effectively everything. if (null == m_consoleAppender.Threshold) m_consoleAppender.Threshold = Level.All; Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold)); } if (m_logFileAppender != null && startupConfig != null) { string cfgFileName = startupConfig.GetString("LogFile", null); if (cfgFileName != null) { m_logFileAppender.File = cfgFileName; m_logFileAppender.ActivateOptions(); } m_log.InfoFormat("[SERVER BASE]: Logging started to file {0}", m_logFileAppender.File); } }
/// <summary> /// Must be overriden by child classes for their own server specific startup behaviour. /// </summary> protected virtual void StartupSpecific() { if (m_console != null) { ILoggerRepository repository = LogManager.GetRepository(); IAppender[] appenders = repository.GetAppenders(); foreach (IAppender appender in appenders) { if (appender.Name == "Console") { m_consoleAppender = (OpenSimAppender)appender; break; } } if (null == m_consoleAppender) { Notice("No appender named Console found (see the log4net config file for this executable)!"); } else { m_consoleAppender.Console = m_console; // If there is no threshold set then the threshold is effectively everything. if (null == m_consoleAppender.Threshold) m_consoleAppender.Threshold = Level.All; Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold)); } m_console.Commands.AddCommand("base", false, "quit", "quit", "Quit the application", HandleQuit); m_console.Commands.AddCommand("base", false, "shutdown", "shutdown", "Quit the application", HandleQuit); m_console.Commands.AddCommand("base", false, "set log level", "set log level <level>", "Set the console logging level", HandleLogLevel); m_console.Commands.AddCommand("base", false, "show info", "show info", "Show general information", HandleShow); m_console.Commands.AddCommand("base", false, "show stats", "show stats", "Show statistics", HandleShow); m_console.Commands.AddCommand("base", false, "show threads", "show threads", "Show thread status", HandleShow); m_console.Commands.AddCommand("base", false, "show uptime", "show uptime", "Show server uptime", HandleShow); m_console.Commands.AddCommand("base", false, "show version", "show version", "Show server version", HandleShow); } }