adding -logconfig to Robust.exe

Adding -logconfig to Robust.exe. will still process the
	-logfile option, as before. No options given, the value
	"Robust.log" will be written in the ./bin directory
viewer-2-initial-appearance
BlueWall 2010-09-30 23:08:36 -04:00 committed by Melanie
parent eb58d91098
commit ffc1123ca5
2 changed files with 21 additions and 7 deletions

View File

@ -85,11 +85,13 @@ namespace OpenSim.Server.Base
argvConfig.AddSwitch("Startup", "logfile", "l"); argvConfig.AddSwitch("Startup", "logfile", "l");
argvConfig.AddSwitch("Startup", "inifile", "i"); argvConfig.AddSwitch("Startup", "inifile", "i");
argvConfig.AddSwitch("Startup", "prompt", "p"); argvConfig.AddSwitch("Startup", "prompt", "p");
argvConfig.AddSwitch("Startup", "logconfig", "g");
// Automagically create the ini file name // Automagically create the ini file name
// //
string fileName = Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location); string fileName = Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location);
string iniFile = fileName + ".ini"; string iniFile = fileName + ".ini";
string logConfig = null;
IConfig startupConfig = argvConfig.Configs["Startup"]; IConfig startupConfig = argvConfig.Configs["Startup"];
if (startupConfig != null) if (startupConfig != null)
@ -100,6 +102,9 @@ namespace OpenSim.Server.Base
// //
// Check if a prompt was given on the command line // Check if a prompt was given on the command line
prompt = startupConfig.GetString("prompt", prompt); prompt = startupConfig.GetString("prompt", prompt);
//
// Check for a Log4Net config file on the command line
logConfig =startupConfig.GetString("logconfig",logConfig);
} }
// Find out of the file name is a URI and remote load it // Find out of the file name is a URI and remote load it
@ -171,7 +176,15 @@ namespace OpenSim.Server.Base
OpenSimAppender consoleAppender = null; OpenSimAppender consoleAppender = null;
FileAppender fileAppender = null; FileAppender fileAppender = null;
XmlConfigurator.Configure(); if ( logConfig != null )
{
FileInfo cfg = new FileInfo(logConfig);
XmlConfigurator.Configure(cfg);
}
else
{
XmlConfigurator.Configure();
}
ILoggerRepository repository = LogManager.GetRepository(); ILoggerRepository repository = LogManager.GetRepository();
IAppender[] appenders = repository.GetAppenders(); IAppender[] appenders = repository.GetAppenders();
@ -207,11 +220,12 @@ namespace OpenSim.Server.Base
{ {
if (startupConfig != null) if (startupConfig != null)
{ {
string cfgFileName = startupConfig.GetString("logfile", null);
fileName = startupConfig.GetString("logfile", fileName+".log"); if (cfgFileName != null)
fileName = Path.GetFullPath(Path.Combine(".", fileName)); {
fileAppender.File = fileName; fileAppender.File = cfgFileName;
fileAppender.ActivateOptions(); fileAppender.ActivateOptions();
}
} }
} }

View File

@ -17,7 +17,7 @@
</appender> </appender>
<appender name="LogFileAppender" type="log4net.Appender.FileAppender"> <appender name="LogFileAppender" type="log4net.Appender.FileAppender">
<file value="OpenSim.log" /> <file value="Robust.log" />
<appendToFile value="true" /> <appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %-5level - %logger %message%newline" /> <conversionPattern value="%date %-5level - %logger %message%newline" />