// actual initialization process from a given input stream private synchronized void readConfigurationImpl(InputStream ins) throws IOException { reset(); props.load(ins); // The RI treats the root logger as special. For compatibility, always // update the root logger's handlers. Logger root = loggers.get(""); if (root != null) { root.setManager(this); } // parse property "config" and apply setting String configs = props.getProperty("config"); if (configs != null) { StringTokenizer st = new StringTokenizer(configs, " "); while (st.hasMoreTokens()) { String configerName = st.nextToken(); getInstanceByClass(configerName); } } // set levels for logger Collection<Logger> allLoggers = loggers.values(); for (Logger logger : allLoggers) { String property = props.getProperty(logger.getName() + ".level"); if (property != null) { logger.setLevel(Level.parse(property)); } } listeners.firePropertyChange(null, null, null); }
/** * Add a given logger into the hierarchical namespace. The {@code Logger.addLogger()} factory * methods call this method to add newly created Logger. This returns false if a logger with the * given name has existed in the namespace * * <p>Note that the {@code LogManager} may only retain weak references to registered loggers. In * order to prevent {@code Logger} objects from being unexpectedly garbage collected it is * necessary for <i>applications</i> to maintain references to them. * * @param logger the logger to be added. * @return true if the given logger is added into the namespace successfully, false if the given * logger exists in the namespace. */ public synchronized boolean addLogger(Logger logger) { String name = logger.getName(); if (loggers.get(name) != null) { return false; } addToFamilyTree(logger, name); loggers.put(name, logger); logger.setManager(this); return true; }