@Override public void run() { if (useShutdownHook) { shutdown(); } }
if (configFileStr != null) { try { is = new FileInputStream(replace(configFileStr)); } catch (IOException e) { ClassLoaderLogInfo info = null; while (current != null && info == null) { info = getClassLoaderInfo(current); current = current.getParent(); readConfiguration(is, classLoader); addLogger(localRootLogger);
@Override public void readConfiguration(InputStream is) throws IOException, SecurityException { checkAccess(); reset(); readConfiguration(is, Thread.currentThread().getContextClassLoader()); }
@Override public void readConfiguration() throws IOException, SecurityException { checkAccess(); readConfiguration(Thread.currentThread().getContextClassLoader()); }
@Override public void reset() throws SecurityException { Thread thread = Thread.currentThread(); if (thread.getClass().getName().startsWith( "java.util.logging.LogManager$")) { // Ignore the call from java.util.logging.LogManager.Cleaner, // because we have our own shutdown hook return; } ClassLoader classLoader = thread.getContextClassLoader(); ClassLoaderLogInfo clLogInfo = getClassLoaderInfo(classLoader); resetLoggers(clLogInfo); super.reset(); }
ClassLoaderLogInfo info = getClassLoaderInfo(classLoader); if (info.loggers.containsKey(loggerName)) { return false; final String levelString = getProperty(loggerName + ".level"); if (levelString != null) { try { doSetParentLogger(logger, parentLogger); String handlers = getProperty(loggerName + ".handlers"); if (handlers != null) { logger.setUseParentHandlers(false); String useParentHandlersString = getProperty(loggerName + ".useParentHandlers"); if (Boolean.valueOf(useParentHandlersString).booleanValue()) { logger.setUseParentHandlers(true);
/** * Get the value of the specified property in the classloader local * configuration. * * @param name The property name */ @Override public String getProperty(String name) { String prefix = this.prefix.get(); String result = null; // If a prefix is defined look for a prefixed property first if (prefix != null) { result = findProperty(prefix + name); } // If there is no prefix or no property match with the prefix try just // the name if (result == null) { result = findProperty(name); } // Simple property replacement (mostly for folder names) if (result != null) { result = replace(result); } return result; }
void setParentLogger(final Logger parent) { for (final Iterator<LogNode> iter = children.values().iterator(); iter.hasNext();) { final LogNode childNode = iter.next(); if (childNode.logger == null) { childNode.setParentLogger(parent); } else { doSetParentLogger(childNode.logger, parent); } } }
/** * Shuts down the logging system. */ public void shutdown() { // The JVM is being shutdown. Make sure all loggers for all class // loaders are shutdown for (ClassLoaderLogInfo clLogInfo : classLoaderLoggers.values()) { resetLoggers(clLogInfo); } }
/** * Get an enumeration of the logger names currently defined in the * classloader local configuration. */ @Override public synchronized Enumeration<String> getLoggerNames() { ClassLoader classLoader = Thread.currentThread() .getContextClassLoader(); return Collections.enumeration(getClassLoaderInfo(classLoader).loggers.keySet()); }
name = prefix + name; ClassLoaderLogInfo info = getClassLoaderInfo(classLoader); String result = info.props.getProperty(name); result = replace(result);
/** * System property replacement in the given string. * * @param str The original string * @return the modified string */ protected String replace(String str) { String result = str; int pos_start = result.indexOf("${"); if (pos_start != -1) { int pos_end = result.indexOf('}'); if (pos_end != -1) { String propName = result.substring(pos_start + 2, pos_end); String replacement = System.getProperty(propName); if (replacement != null) { if(pos_start >0) { result = result.substring(0,pos_start) + replacement + replace(result.substring(pos_end + 1)); } else { result = replacement + replace(result.substring(pos_end + 1)); } } } } return result; }
@Override public Void run() { try { readConfiguration(classLoaderParam); } catch (IOException e) { // Ignore } return null; } });
ClassLoaderLogInfo info = getClassLoaderInfo(classLoader); if (info.loggers.containsKey(loggerName)) { return false; final String levelString = getProperty(loggerName + ".level"); if (levelString != null) { try { doSetParentLogger(logger, parentLogger); String handlers = getProperty(loggerName + ".handlers"); if (handlers != null) { logger.setUseParentHandlers(false); String useParentHandlersString = getProperty(loggerName + ".useParentHandlers"); if (Boolean.valueOf(useParentHandlersString).booleanValue()) { logger.setUseParentHandlers(true);
@Override public void readConfiguration() throws IOException, SecurityException { checkAccess(); readConfiguration(Thread.currentThread().getContextClassLoader()); }
/** * Get the value of the specified property in the classloader local * configuration. * * @param name The property name */ @Override public String getProperty(String name) { String prefix = this.prefix.get(); String result = null; // If a prefix is defined look for a prefixed property first if (prefix != null) { result = findProperty(prefix + name); } // If there is no prefix or no property match with the prefix try just // the name if (result == null) { result = findProperty(name); } // Simple property replacement (mostly for folder names) if (result != null) { result = replace(result); } return result; }
void setParentLogger(final Logger parent) { for (final Iterator<LogNode> iter = children.values().iterator(); iter.hasNext();) { final LogNode childNode = iter.next(); if (childNode.logger == null) { childNode.setParentLogger(parent); } else { doSetParentLogger(childNode.logger, parent); } } }
/** * Shuts down the logging system. */ public void shutdown() { // The JVM is being shutdown. Make sure all loggers for all class // loaders are shutdown for (ClassLoaderLogInfo clLogInfo : classLoaderLoggers.values()) { resetLoggers(clLogInfo); } }
/** * Get the logger associated with the specified name inside * the classloader local configuration. If this returns null, * and the call originated for Logger.getLogger, a new * logger with the specified name will be instantiated and * added using addLogger. * * @param name The name of the logger to retrieve */ @Override public synchronized Logger getLogger(final String name) { ClassLoader classLoader = Thread.currentThread() .getContextClassLoader(); return getClassLoaderInfo(classLoader).loggers.get(name); }
/** * System property replacement in the given string. * * @param str The original string * @return the modified string */ protected String replace(String str) { String result = str; int pos_start = result.indexOf("${"); if (pos_start != -1) { int pos_end = result.indexOf('}'); if (pos_end != -1) { String propName = result.substring(pos_start + 2, pos_end); String replacement = System.getProperty(propName); if (replacement != null) { if(pos_start >0) { result = result.substring(0,pos_start) + replacement + replace(result.substring(pos_end + 1)); } else { result = replacement + replace(result.substring(pos_end + 1)); } } } } return result; }