1 package org.objectweb.kilim; 2 3 import java.util.Properties ; 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 11 public class KilimLoggerFactory implements LoggerFactory { 12 13 private static LoggerFactory singleton; 14 15 static { 16 17 Properties prprts = System.getProperties(); 18 String 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 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 41 public static LoggerFactory getSingleton() { 42 return singleton; 43 } 44 45 48 public Logger[] getLoggers() { 49 return singleton.getLoggers(); 50 } 51 52 55 public Logger getLogger(String key) { 56 return singleton.getLogger(key); 57 } 58 59 62 public Logger getLogger(String key, String resource_bundle_name) { 63 return singleton.getLogger(key, resource_bundle_name); 64 } 65 66 69 public String getResourceBundleName() { 70 return singleton.getResourceBundleName(); 71 } 72 73 76 public void setResourceBundleName(String resource_bundle_name) { 77 singleton.setResourceBundleName(resource_bundle_name); 78 } 79 80 } 81 | Popular Tags |