/**
* Copyright (C) 2001-2003 France Telecom R&D
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import org.objectweb.util.monolog.api.MonologFactory;
import java.util.Properties;
/**
*
* @author Sebastien Chassande-Barrioz
*/
public class SpecificConf {
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Syntax error !");
System.out.println(
"java SpecificConf <logger factory class name> <mode> "
+ "[<config file name> [ true | false ]]");
System.exit(1);
}
// Instanciate the logger factory
MonologFactory lf = null;
try {
lf = (MonologFactory) Class.forName(args[0]).newInstance();
} catch (ClassCastException e) {
throw new ClassCastException(
"The specified class is not a Logger factory: " + args[0]);
} catch (Exception e) {
throw new ClassCastException(
"Logger factory class is not availlable: " + args[0]);
}
String mode = (args.length>1 ? args[1] : null);
Properties prop = null;
if (mode != null && !mode.equalsIgnoreCase("null")) {
String configFileName = (args.length>2 ? args[2] : null);
prop = new Properties();
prop.put(MonologFactory.LOG_CONFIGURATION_TYPE, mode);
if (configFileName != null) {
prop.put(MonologFactory.LOG_CONFIGURATION_FILE, configFileName);
}
String useClassPath = (args.length>3 ? args[3] : null);
if (useClassPath != null) {
prop.put(MonologFactory.LOG_CONFIGURATION_FILE_USE_CLASSPATH,
useClassPath);
}
}
//load the configuration
try {
lf.configure(prop);
} catch (Exception e) {
System.out.println("Impossible to configure in " + mode + " mode: "
+ e.getMessage());
System.exit(1);
}
Simple sc = new Simple(lf);
sc.foo();
sc.bar();
}
}