System.err.println("FATAL ERROR: Reading configuration file '" + name + "'");
e.printStackTrace(System.err);
System.exit(1);
}
final Document doc = tmp;
config = new Configuration(doc);
Configuration serverConfig = config.getChild(SERVER);
try {
boolean logging = config.getBooleanAttribute(LOGGING, true);
if ( logging ) {
// Hijack System.out and System.err
File logFile = null;
String log = config.getAttribute(LOG);
if ( log != null && log.length() > 0 )
logFile = new File(log);
else
logFile = new File(new File(System.getProperty(dbXML.PROP_DBXML_HOME)), LOG_FILE);
if ( logFile != null ) {
boolean header = !logFile.exists();
System.out.println("Logging to " + logFile.getPath());
FileOutputStream fos = new FileOutputStream(logFile.getPath(), true);
LoggingStream ls = new LoggingStream(fos);
PrintStream ps = new PrintStream(ls, true);
if ( header ) {
String s = dbXML.Title + " " + dbXML.Version + " Console Log File";
ps.println(s);
StringBuffer sb = new StringBuffer(s.length());
for ( int i = 0; i < s.length(); i++ )
sb.append('-');
ps.println(sb.toString());
}
System.setOut(ps);
System.setErr(ps);
}
}
else
System.out.println("Logging to standard output");
}
catch ( Exception e ) {
System.err.println("FATAL ERROR: Can't override standard logging");
e.printStackTrace(System.err);
System.exit(1);
}
System.out.println("Server startup");
// Configure the Service Manager
services.setServer(this);
services.setConfig(serverConfig.getChild(SERVICES));
if ( !services.startServices() ) {
System.err.println("FATAL ERROR: Service manager could not be started");
System.exit(1);
}