1 5 package org.exoplatform.services.log; 6 7 import org.apache.commons.logging.Log; 8 import org.exoplatform.container.RootContainer; 9 10 16 public class LogUtil { 17 static private Log defaultInstance_ = null ; 18 19 public static Log getLog(String category) { 20 RootContainer manager = RootContainer.getInstance(); 21 LogService service = (LogService) manager.getComponentInstanceOfType(LogService.class) ; 22 Log log = service.getLog(category) ; 23 return log ; 24 } 25 26 public static Log getLog(Class clazz) { 27 RootContainer manager = RootContainer.getInstance(); 28 LogService service = (LogService) manager.getComponentInstanceOfType(LogService.class) ; 29 Log log = service.getLog(clazz) ; 30 return log ; 31 } 32 33 public static void setLevel(String category, int level, boolean recursive) throws Exception { 34 RootContainer manager = RootContainer.getInstance(); 35 LogService service = (LogService) manager.getComponentInstanceOfType(LogService.class) ; 36 service.setLogLevel(category, level, recursive) ; 37 } 38 39 static public void debug(String msg) { getDefault().debug(msg) ; } 40 static public void debug(String msg, Throwable t) { getDefault().debug(msg, t) ; } 41 42 static public void info(String msg) { getDefault().info(msg) ; } 43 static public void info(String msg, Throwable t) { getDefault().info(msg, t) ; } 44 45 static public void warn(String msg) { getDefault().warn(msg) ; } 46 static public void warn(String msg, Throwable t) { getDefault().warn(msg, t) ; } 47 48 static public void error(String msg) { getDefault().error(msg) ; } 49 static public void error(String msg, Throwable t) { getDefault().error(msg, t) ; } 50 51 final static public Log getDefault() { 52 if(defaultInstance_ == null) { 53 defaultInstance_ = getLog("default") ; 54 } 55 return defaultInstance_ ; 56 } 57 } | Popular Tags |