1 20 21 package org.snmp4j.log; 22 23 import java.util.Iterator ; 24 import java.util.logging.Logger ; 25 import java.util.logging.LogManager ; 26 import java.util.*; 27 28 37 public class JavaLogFactory extends LogFactory { 38 39 public JavaLogFactory() { 40 } 41 42 protected LogAdapter createLogger(Class c) { 43 return new JavaLogAdapter(Logger.getLogger(c.getClass().getName())); 44 } 45 46 protected LogAdapter createLogger(String className) { 47 return new JavaLogAdapter(Logger.getLogger(className)); 48 } 49 50 public LogAdapter getRootLogger() { 51 return new JavaLogAdapter(Logger.getLogger("")); 52 } 53 54 public Iterator loggers() { 55 Enumeration loggerNames = LogManager.getLogManager().getLoggerNames(); 56 return new JavaLogAdapterIterator(loggerNames); 57 } 58 59 public class JavaLogAdapterIterator implements Iterator { 60 private Enumeration loggerNames; 61 62 protected JavaLogAdapterIterator(Enumeration loggerNames) { 63 this.loggerNames = loggerNames; 64 } 65 66 public void remove() { 67 throw new UnsupportedOperationException (); 68 } 69 70 public final boolean hasNext() { 71 return loggerNames.hasMoreElements(); 72 } 73 74 public Object next() { 75 String loggerName = (String ) loggerNames.nextElement(); 76 Logger logger = Logger.getLogger(loggerName); 77 return new JavaLogAdapter(logger); 78 } 79 } 80 } 81 | Popular Tags |