Allow setting the stats log file location in OpenSim.ini rather than app.exe.config

melanie
Melanie Thielker 2017-02-24 01:33:02 +00:00
parent 41d21190b1
commit adcb1d8798
2 changed files with 31 additions and 1 deletions

View File

@ -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);
}
}
/// <summary>

View File

@ -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());