1 8 9 package mx4j.log; 10 11 17 public class CommonsLogger extends Logger 18 { 19 private org.apache.commons.logging.Log log = null; 20 21 public CommonsLogger() 22 { 23 } 24 25 protected void setCategory(String category) 26 { 27 super.setCategory(category); 28 log = org.apache.commons.logging.LogFactory.getLog(getCategory()); 29 } 30 31 protected void log(int priority, Object message, Throwable t) 32 { 33 switch (priority) 34 { 35 case Logger.FATAL: 36 if (t == null) 37 log.fatal(message); 38 else 39 log.fatal(message, t); 40 break; 41 case Logger.ERROR: 42 if (t == null) 43 log.error(message); 44 else 45 log.error(message, t); 46 break; 47 case Logger.WARN: 48 if (t == null) 49 log.warn(message); 50 else 51 log.warn(message, t); 52 break; 53 case Logger.INFO: 54 if (t == null) 55 log.info(message); 56 else 57 log.info(message, t); 58 break; 59 case Logger.DEBUG: 60 if (t == null) 61 log.debug(message); 62 else 63 log.debug(message, t); 64 break; 65 case Logger.TRACE: 66 if (t == null) 67 log.trace(message); 68 else 69 log.trace(message, t); 70 break; 71 } 72 } 73 } 74 | Popular Tags |