1 20 21 package org.snmp4j.log; 22 23 import org.apache.log4j.Logger; 24 import java.util.Iterator ; 25 import java.util.Collections ; 26 import java.util.ArrayList ; 27 28 38 public class Log4jLogFactory extends LogFactory { 39 40 public Log4jLogFactory() { 41 } 42 43 protected LogAdapter createLogger(Class c) { 44 return new Log4jLogAdapter(Logger.getLogger(c)); 45 } 46 47 protected LogAdapter createLogger(String className) { 48 return new Log4jLogAdapter(Logger.getLogger(className)); 49 } 50 51 public LogAdapter getRootLogger() { 52 return new Log4jLogAdapter(Logger.getRootLogger()); 53 } 54 55 public Iterator loggers() { 56 ArrayList l = Collections.list(Logger.getRootLogger(). 57 getLoggerRepository(). 58 getCurrentLoggers()); 59 for (int i=0; i < l.size(); i++) { 60 l.set(i, new Log4jLogAdapter((Logger)l.get(i))); 61 } 62 Collections.sort(l); 63 return l.iterator(); 64 } 65 } 66 | Popular Tags |