From adcb1d8798c0404d0c9f894d1b33003557066123 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 24 Feb 2017 01:33:02 +0000 Subject: Allow setting the stats log file location in OpenSim.ini rather than app.exe.config --- OpenSim/Framework/Servers/ServerBase.cs | 17 +++++++++++++++++ OpenSim/Framework/Util.cs | 15 ++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs index 8965e71..f627ae6 100644 --- a/OpenSim/Framework/Servers/ServerBase.cs +++ b/OpenSim/Framework/Servers/ServerBase.cs @@ -57,6 +57,7 @@ namespace OpenSim.Framework.Servers protected OpenSimAppender m_consoleAppender; protected FileAppender m_logFileAppender; + protected FileAppender m_statsLogFileAppender; protected DateTime m_startuptime; protected string m_startupDirectory = Environment.CurrentDirectory; @@ -156,6 +157,10 @@ namespace OpenSim.Framework.Servers { m_logFileAppender = (FileAppender)appender; } + else if (appender.Name == "StatsLogFileAppender") + { + m_statsLogFileAppender = (FileAppender)appender; + } } if (null == m_consoleAppender) @@ -185,6 +190,18 @@ namespace OpenSim.Framework.Servers m_log.InfoFormat("[SERVER BASE]: Logging started to file {0}", m_logFileAppender.File); } + + if (m_statsLogFileAppender != null && startupConfig != null) + { + string cfgStatsFileName = startupConfig.GetString("StatsLogFile", null); + if (cfgStatsFileName != null) + { + m_statsLogFileAppender.File = cfgStatsFileName; + m_statsLogFileAppender.ActivateOptions(); + } + + m_log.InfoFormat("[SERVER BASE]: Stats Logging started to file {0}", m_statsLogFileAppender.File); + } } /// diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 0037f4f..dcb660a 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -1190,7 +1190,7 @@ namespace OpenSim.Framework { foreach (IAppender appender in LogManager.GetRepository().GetAppenders()) { - if (appender is FileAppender) + if (appender is FileAppender && appender.Name == "LogFileAppender") { return ((FileAppender)appender).File; } @@ -1199,6 +1199,19 @@ namespace OpenSim.Framework return "./OpenSim.log"; } + public static string statsLogFile() + { + foreach (IAppender appender in LogManager.GetRepository().GetAppenders()) + { + if (appender is FileAppender && appender.Name == "StatsLogFileAppender") + { + return ((FileAppender)appender).File; + } + } + + return "./OpenSimStats.log"; + } + public static string logDir() { return Path.GetDirectoryName(logFile()); -- cgit v1.1