KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > kilim > KilimLoggerFactory


1 package org.objectweb.kilim;
2
3 import java.util.Properties JavaDoc;
4
5 import org.objectweb.util.monolog.api.Logger;
6 import org.objectweb.util.monolog.api.LoggerFactory;
7 import org.objectweb.util.monolog.wrapper.log4j.MonologLoggerFactory;
8 /**
9  * @author delpiano
10  */

11 public class KilimLoggerFactory implements LoggerFactory {
12
13     private static LoggerFactory singleton;
14
15     static {
16         
17         Properties JavaDoc prprts = System.getProperties();
18         String JavaDoc log = prprts.getProperty("org.objectweb.kilim.log");
19         boolean log_on = false;
20         if (log != null) {
21             log_on = log.equals("true");
22         }
23         
24         if (log_on) {
25             try {
26                 singleton = new MonologLoggerFactory();
27             } catch (Throwable JavaDoc e) {
28                 System.out.println("KILIM WARNING : No Logger found, disabling logging functionality for Kilim module.");
29                 singleton = new NullLoggerFactory();
30             }
31         } else {
32             singleton = new NullLoggerFactory();
33         }
34             
35     }
36
37     /**
38      * returns the LoggerFactory.
39      * @return LoggerFactory
40      */

41     public static LoggerFactory getSingleton() {
42         return singleton;
43     }
44
45     /**
46      * @see org.objectweb.util.monolog.api.LoggerFactory#getLogger(String)
47      */

48     public Logger[] getLoggers() {
49         return singleton.getLoggers();
50     }
51
52     /**
53      * @see org.objectweb.util.monolog.api.LoggerFactory#getLogger(String)
54      */

55     public Logger getLogger(String JavaDoc key) {
56         return singleton.getLogger(key);
57     }
58
59     /**
60      * @see org.objectweb.util.monolog.api.LoggerFactory#getLogger(String, String)
61      */

62     public Logger getLogger(String JavaDoc key, String JavaDoc resource_bundle_name) {
63         return singleton.getLogger(key, resource_bundle_name);
64     }
65
66     /**
67      * @see org.objectweb.util.monolog.api.LoggerFactory#getResourceBundleName()
68      */

69     public String JavaDoc getResourceBundleName() {
70         return singleton.getResourceBundleName();
71     }
72
73     /**
74      * @see org.objectweb.util.monolog.api.LoggerFactory#setResourceBundleName(String)
75      */

76     public void setResourceBundleName(String JavaDoc resource_bundle_name) {
77         singleton.setResourceBundleName(resource_bundle_name);
78     }
79
80 }
81
Popular Tags