1 package liquibase.logging; 2 3 import liquibase.exception.ServiceNotFoundException; 4 import liquibase.servicelocator.ServiceLocator; 5 6 import java.util.HashMap; 7 import java.util.Map; 8 9 public class LogFactory { 10 private static Map<String, Logger> loggers = new HashMap<String, Logger>(); 11 private static String defaultLoggingLevel = "info"; 12 13 public static Logger getLogger(String name) { 14 if (!loggers.containsKey(name)) { 15 Logger value; 16 try { 17 value = (Logger) ServiceLocator.getInstance().newInstance(Logger.class); 18 } catch (Exception e) { 19 throw new ServiceNotFoundException(e); 20 } 21 value.setName(name); 22 value.setLogLevel(defaultLoggingLevel); 23 loggers.put(name, value); 24 } 25 26 return loggers.get(name); 27 } 28 29 public static Logger getLogger() { 30 return getLogger("liquibase"); 31 } 32 33 public static void setLoggingLevel(String defaultLoggingLevel) { 34 LogFactory.defaultLoggingLevel = defaultLoggingLevel; 35 } 36 }