WebStats will now use actual logfile as specified in OpenSim.exe.config rather than hardcoded ./OpenSim.log. This allows for rotating logs and other file appender types

user_profiles
Dan Lake 2013-02-06 16:42:55 -08:00
parent dce9e323f4
commit df37738ce7
2 changed files with 16 additions and 2 deletions

View File

@ -45,6 +45,7 @@ using System.Text.RegularExpressions;
using System.Xml;
using System.Threading;
using log4net;
using log4net.Appender;
using Nini.Config;
using Nwc.XmlRpc;
using OpenMetaverse;
@ -816,9 +817,22 @@ namespace OpenSim.Framework
return ".";
}
public static string logFile()
{
foreach (IAppender appender in LogManager.GetRepository().GetAppenders())
{
if (appender is FileAppender)
{
return ((FileAppender)appender).File;
}
}
return "./OpenSim.log";
}
public static string logDir()
{
return ".";
return Path.GetDirectoryName(logFile());
}
// From: http://coercedcode.blogspot.com/2008/03/c-generate-unique-filenames-within.html

View File

@ -420,7 +420,7 @@ namespace OpenSim.Region.UserStatistics
Encoding encoding = Encoding.ASCII;
int sizeOfChar = encoding.GetByteCount("\n");
byte[] buffer = encoding.GetBytes("\n");
string logfile = Util.logDir() + "/" + "OpenSim.log";
string logfile = Util.logFile();
FileStream fs = new FileStream(logfile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
Int64 tokenCount = 0;
Int64 endPosition = fs.Length / sizeOfChar;