Package org.apache.juli
Class ClassLoaderLogManager
- java.lang.Object
-
- java.util.logging.LogManager
-
- org.apache.juli.ClassLoaderLogManager
-
public class ClassLoaderLogManager extends java.util.logging.LogManagerPer classloader LogManager implementation. For light debugging, set the system propertyorg.apache.juli.ClassLoaderLogManager.debug=true. Short configuration information will be sent toSystem.err.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classClassLoaderLogManager.ClassLoaderLogInfoprotected static classClassLoaderLogManager.LogNodeprotected static classClassLoaderLogManager.RootLoggerThis class is needed to instantiate the root of each per classloader hierarchy.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.ClassLoader,ClassLoaderLogManager.ClassLoaderLogInfo>classLoaderLoggersMap containing the classloader information, keyed per classloader.static java.lang.StringDEBUG_PROPERTYprotected java.lang.ThreadLocal<java.lang.String>prefixThis prefix is used to allow using prefixes for the properties names of handlers and their subcomponents.protected booleanuseShutdownHookDetermines if the shutdown hook is used to perform any necessary clean-up such as flushing buffered handlers on JVM shutdown.
-
Constructor Summary
Constructors Constructor Description ClassLoaderLogManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddLogger(java.util.logging.Logger logger)Add the specified logger to the classloader local configuration.protected static voiddoSetParentLogger(java.util.logging.Logger logger, java.util.logging.Logger parent)Set parent child relationship between the two specified loggers.protected ClassLoaderLogManager.ClassLoaderLogInfogetClassLoaderInfo(java.lang.ClassLoader classLoader)Retrieve the configuration associated with the specified classloader.java.util.logging.LoggergetLogger(java.lang.String name)Get the logger associated with the specified name inside the classloader local configuration.java.util.Enumeration<java.lang.String>getLoggerNames()Get an enumeration of the logger names currently defined in the classloader local configuration.java.lang.StringgetProperty(java.lang.String name)Get the value of the specified property in the classloader local configuration.booleanisUseShutdownHook()voidreadConfiguration()voidreadConfiguration(java.io.InputStream is)protected voidreadConfiguration(java.io.InputStream is, java.lang.ClassLoader classLoader)Load specified configuration.protected voidreadConfiguration(java.lang.ClassLoader classLoader)Read configuration for the specified classloader.protected java.lang.Stringreplace(java.lang.String str)System property replacement in the given string.voidreset()voidsetUseShutdownHook(boolean useShutdownHook)voidshutdown()Shuts down the logging system.
-
-
-
Field Detail
-
DEBUG_PROPERTY
public static final java.lang.String DEBUG_PROPERTY
-
classLoaderLoggers
protected final java.util.Map<java.lang.ClassLoader,ClassLoaderLogManager.ClassLoaderLogInfo> classLoaderLoggers
Map containing the classloader information, keyed per classloader. A weak hashmap is used to ensure no classloader reference is leaked from application redeployment.
-
prefix
protected final java.lang.ThreadLocal<java.lang.String> prefix
This prefix is used to allow using prefixes for the properties names of handlers and their subcomponents.
-
useShutdownHook
protected volatile boolean useShutdownHook
Determines if the shutdown hook is used to perform any necessary clean-up such as flushing buffered handlers on JVM shutdown. Defaults totruebut may be set to false if another component ensures thatshutdown()is called.
-
-
Method Detail
-
isUseShutdownHook
public boolean isUseShutdownHook()
-
setUseShutdownHook
public void setUseShutdownHook(boolean useShutdownHook)
-
addLogger
public boolean addLogger(java.util.logging.Logger logger)
Add the specified logger to the classloader local configuration.- Overrides:
addLoggerin classjava.util.logging.LogManager- Parameters:
logger- The logger to be added
-
getLogger
public java.util.logging.Logger getLogger(java.lang.String name)
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.- Overrides:
getLoggerin classjava.util.logging.LogManager- Parameters:
name- The name of the logger to retrieve
-
getLoggerNames
public java.util.Enumeration<java.lang.String> getLoggerNames()
Get an enumeration of the logger names currently defined in the classloader local configuration.- Overrides:
getLoggerNamesin classjava.util.logging.LogManager
-
getProperty
public java.lang.String getProperty(java.lang.String name)
Get the value of the specified property in the classloader local configuration.- Overrides:
getPropertyin classjava.util.logging.LogManager- Parameters:
name- The property name
-
readConfiguration
public void readConfiguration() throws java.io.IOException, java.lang.SecurityException- Overrides:
readConfigurationin classjava.util.logging.LogManager- Throws:
java.io.IOExceptionjava.lang.SecurityException
-
readConfiguration
public void readConfiguration(java.io.InputStream is) throws java.io.IOException, java.lang.SecurityException- Overrides:
readConfigurationin classjava.util.logging.LogManager- Throws:
java.io.IOExceptionjava.lang.SecurityException
-
reset
public void reset() throws java.lang.SecurityException- Overrides:
resetin classjava.util.logging.LogManager- Throws:
java.lang.SecurityException
-
shutdown
public void shutdown()
Shuts down the logging system.
-
getClassLoaderInfo
protected ClassLoaderLogManager.ClassLoaderLogInfo getClassLoaderInfo(java.lang.ClassLoader classLoader)
Retrieve the configuration associated with the specified classloader. If it does not exist, it will be created. If no class loader is specified, the class loader used to load this class is used.- Parameters:
classLoader- The class loader for which we will retrieve or build the configuration- Returns:
- the log configuration
-
readConfiguration
protected void readConfiguration(java.lang.ClassLoader classLoader) throws java.io.IOExceptionRead configuration for the specified classloader.- Parameters:
classLoader- The classloader- Throws:
java.io.IOException- Error reading configuration
-
readConfiguration
protected void readConfiguration(java.io.InputStream is, java.lang.ClassLoader classLoader) throws java.io.IOExceptionLoad specified configuration.- Parameters:
is- InputStream to the properties fileclassLoader- for which the configuration will be loaded- Throws:
java.io.IOException- If something wrong happens during loading
-
doSetParentLogger
protected static void doSetParentLogger(java.util.logging.Logger logger, java.util.logging.Logger parent)Set parent child relationship between the two specified loggers.- Parameters:
logger- The loggerparent- The parent logger
-
replace
protected java.lang.String replace(java.lang.String str)
System property replacement in the given string.- Parameters:
str- The original string- Returns:
- the modified string
-
-