1 8 9 package mx4j.log; 10 11 12 import org.apache.log4j.Category; 13 import org.apache.log4j.Priority; 14 15 22 public class Log4JLogger extends Logger 23 { 24 private Category m_category; 25 26 29 public Log4JLogger() {} 30 31 protected void setCategory(String category) 32 { 33 super.setCategory(category); 34 m_category = Category.getInstance(getCategory()); 35 } 36 37 protected void log(int priority, Object message, Throwable t) 38 { 39 Priority p = convertPriority(priority); 41 m_category.log(p, message, t); 42 } 43 44 47 protected Priority convertPriority(int mx4jPriority) 48 { 49 Priority log4jPriority = Priority.DEBUG; 50 switch (mx4jPriority) 51 { 52 case Logger.FATAL: log4jPriority = Priority.FATAL; break; 53 case Logger.ERROR: log4jPriority = Priority.ERROR; break; 54 case Logger.WARN: log4jPriority = Priority.WARN; break; 55 case Logger.INFO: log4jPriority = Priority.INFO; break; 56 case Logger.DEBUG: log4jPriority = Priority.DEBUG; break; 57 case Logger.TRACE: log4jPriority = Priority.DEBUG; break; 58 default: log4jPriority = Priority.INFO; break; 59 } 60 return log4jPriority; 61 } 62 } 63 | Popular Tags |