KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > monolog > javaLog > TestConfigurability


1 /**
2  * Copyright (C) 2002
3  */

4
5 package org.objectweb.util.monolog.javaLog;
6
7 import org.objectweb.util.monolog.api.Logger;
8 import org.objectweb.util.monolog.api.BasicLevel;
9 import org.objectweb.util.monolog.wrapper.javaLog.LoggerFactory;
10
11 import java.util.Properties JavaDoc;
12
13 /**
14  *
15  * @author Sebastien Chassande-Barrioz
16  */

17 public class TestConfigurability {
18     public static void main(String JavaDoc args[]) {
19         String JavaDoc configMode = args[0];
20         String JavaDoc configParam = null;
21         if (args.length>=2)
22             configParam = args[1];
23
24         Properties JavaDoc prop = new Properties JavaDoc();
25
26         prop.put(LoggerFactory.JAVALOG_CONFIGURATION, configMode);
27         if (configParam!=null) {
28             if (configMode.equals(LoggerFactory.PROPERTY))
29                 prop.put(LoggerFactory.JAVALOG_CONFIGURATION_FILE, configParam);
30             else if (configMode.equals(LoggerFactory.PROPERTY))
31                 prop.put(LoggerFactory.JAVALOG_CONFIGURATION_CLASS, configParam);
32         }
33         System.out.println("Test the configurability with in " + configMode
34             + " mode");
35
36         LoggerFactory mlf = new LoggerFactory();
37         try {
38             mlf.configure(prop);
39         }
40         catch (Exception JavaDoc e) {
41             System.out.println("Impossible to configure in " + configMode
42                 + "mode");
43             e.printStackTrace();
44             System.exit(12);
45         }
46
47         Logger l = mlf.getLogger("org.objectweb.monolog.javalog.test.toto");
48         l.log(BasicLevel.INFO, "test PASSED");
49     }
50 }
51
Popular Tags