Package org.apache.juli
Class ClassLoaderLogManager
- java.lang.Object
-
- java.util.logging.LogManager
-
- org.apache.juli.ClassLoaderLogManager
-
public class ClassLoaderLogManager extends LogManager
Per 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 Map<ClassLoader,ClassLoaderLogManager.ClassLoaderLogInfo>classLoaderLoggersMap containing the classloader information, keyed per classloader.static StringDEBUG_PROPERTYprotected ThreadLocal<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.-
Fields inherited from class java.util.logging.LogManager
LOGGING_MXBEAN_NAME
-
-
Constructor Summary
Constructors Constructor Description ClassLoaderLogManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddLogger(Logger logger)Add the specified logger to the classloader local configuration.protected static voiddoSetParentLogger(Logger logger, Logger parent)Set parent child relationship between the two specified loggers.protected ClassLoaderLogManager.ClassLoaderLogInfogetClassLoaderInfo(ClassLoader classLoader)Retrieve the configuration associated with the specified classloader.LoggergetLogger(String name)Get the logger associated with the specified name inside the classloader local configuration.Enumeration<String>getLoggerNames()Get an enumeration of the logger names currently defined in the classloader local configuration.StringgetProperty(String name)Get the value of the specified property in the classloader local configuration.booleanisUseShutdownHook()voidreadConfiguration()voidreadConfiguration(InputStream is)protected voidreadConfiguration(InputStream is, ClassLoader classLoader)Load specified configuration.protected voidreadConfiguration(ClassLoader classLoader)Read configuration for the specified classloader.protected Stringreplace(String str)System property replacement in the given string.voidreset()voidsetUseShutdownHook(boolean useShutdownHook)voidshutdown()Shuts down the logging system.-
Methods inherited from class java.util.logging.LogManager
addConfigurationListener, checkAccess, getLoggingMXBean, getLogManager, removeConfigurationListener, updateConfiguration, updateConfiguration
-
-
-
-
Field Detail
-
DEBUG_PROPERTY
public static final String DEBUG_PROPERTY
-
classLoaderLoggers
protected final Map<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 ThreadLocal<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(Logger logger)
Add the specified logger to the classloader local configuration.- Overrides:
addLoggerin classLogManager- Parameters:
logger- The logger to be added
-
getLogger
public Logger getLogger(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 classLogManager- Parameters:
name- The name of the logger to retrieve
-
getLoggerNames
public Enumeration<String> getLoggerNames()
Get an enumeration of the logger names currently defined in the classloader local configuration.- Overrides:
getLoggerNamesin classLogManager
-
getProperty
public String getProperty(String name)
Get the value of the specified property in the classloader local configuration.- Overrides:
getPropertyin classLogManager- Parameters:
name- The property name
-
readConfiguration
public void readConfiguration() throws IOException, SecurityException- Overrides:
readConfigurationin classLogManager- Throws:
IOExceptionSecurityException
-
readConfiguration
public void readConfiguration(InputStream is) throws IOException, SecurityException
- Overrides:
readConfigurationin classLogManager- Throws:
IOExceptionSecurityException
-
reset
public void reset() throws SecurityException- Overrides:
resetin classLogManager- Throws:
SecurityException
-
shutdown
public void shutdown()
Shuts down the logging system.
-
getClassLoaderInfo
protected ClassLoaderLogManager.ClassLoaderLogInfo getClassLoaderInfo(ClassLoader classLoader)
Retrieve the configuration associated with the specified classloader. If it does not exist, it will be created.- Parameters:
classLoader- The classloader for which we will retrieve or build the configuration- Returns:
- the log configuration
-
readConfiguration
protected void readConfiguration(ClassLoader classLoader) throws IOException
Read configuration for the specified classloader.- Parameters:
classLoader- The classloader- Throws:
IOException- Error reading configuration
-
readConfiguration
protected void readConfiguration(InputStream is, ClassLoader classLoader) throws IOException
Load specified configuration.- Parameters:
is- InputStream to the properties fileclassLoader- for which the configuration will be loaded- Throws:
IOException- If something wrong happens during loading
-
doSetParentLogger
protected static void doSetParentLogger(Logger logger, Logger parent)
Set parent child relationship between the two specified loggers.- Parameters:
logger- The loggerparent- The parent logger
-
-