Package org.apache.logging.log4j.spi
Class LoggerRegistry<T extends ExtendedLogger>
- java.lang.Object
-
- org.apache.logging.log4j.spi.LoggerRegistry<T>
-
public class LoggerRegistry<T extends ExtendedLogger> extends java.lang.ObjectConvenience class to be used byLoggerContextimplementations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLoggerRegistry.ConcurrentMapFactory<T extends ExtendedLogger>Generates ConcurrentHashMaps for use by the registry to store the Loggers.static interfaceLoggerRegistry.MapFactory<T extends ExtendedLogger>Interface to control the data structure used by the registry to store the Loggers.static classLoggerRegistry.WeakMapFactory<T extends ExtendedLogger>Generates WeakHashMaps for use by the registry to store the Loggers.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringDEFAULT_FACTORY_KEYprivate LoggerRegistry.MapFactory<T>factoryprivate java.util.Map<java.lang.String,java.util.Map<java.lang.String,T>>map
-
Constructor Summary
Constructors Constructor Description LoggerRegistry()LoggerRegistry(LoggerRegistry.MapFactory<T> factory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.lang.StringfactoryClassKey(java.lang.Class<? extends MessageFactory> messageFactoryClass)private static java.lang.StringfactoryKey(MessageFactory messageFactory)TgetLogger(java.lang.String name)Returns an ExtendedLogger.TgetLogger(java.lang.String name, MessageFactory messageFactory)Returns an ExtendedLogger.java.util.Collection<T>getLoggers()java.util.Collection<T>getLoggers(java.util.Collection<T> destination)private java.util.Map<java.lang.String,T>getOrCreateInnerMap(java.lang.String factoryName)booleanhasLogger(java.lang.String name)Detects if a Logger with the specified name exists.booleanhasLogger(java.lang.String name, java.lang.Class<? extends MessageFactory> messageFactoryClass)Detects if a Logger with the specified name and MessageFactory type exists.booleanhasLogger(java.lang.String name, MessageFactory messageFactory)Detects if a Logger with the specified name and MessageFactory exists.voidputIfAbsent(java.lang.String name, MessageFactory messageFactory, T logger)
-
-
-
Field Detail
-
DEFAULT_FACTORY_KEY
private static final java.lang.String DEFAULT_FACTORY_KEY
-
factory
private final LoggerRegistry.MapFactory<T extends ExtendedLogger> factory
-
map
private final java.util.Map<java.lang.String,java.util.Map<java.lang.String,T extends ExtendedLogger>> map
-
-
Constructor Detail
-
LoggerRegistry
public LoggerRegistry()
-
LoggerRegistry
public LoggerRegistry(LoggerRegistry.MapFactory<T> factory)
-
-
Method Detail
-
factoryClassKey
private static java.lang.String factoryClassKey(java.lang.Class<? extends MessageFactory> messageFactoryClass)
-
factoryKey
private static java.lang.String factoryKey(MessageFactory messageFactory)
-
getLogger
public T getLogger(java.lang.String name)
Returns an ExtendedLogger.- Parameters:
name- The name of the Logger to return.- Returns:
- The logger with the specified name.
-
getLogger
public T getLogger(java.lang.String name, MessageFactory messageFactory)
Returns an ExtendedLogger.- Parameters:
name- The name of the Logger to return.messageFactory- The message factory is used only when creating a logger, subsequent use does not change the logger but will log a warning if mismatched.- Returns:
- The logger with the specified name.
-
getLoggers
public java.util.Collection<T> getLoggers()
-
getOrCreateInnerMap
private java.util.Map<java.lang.String,T> getOrCreateInnerMap(java.lang.String factoryName)
-
hasLogger
public boolean hasLogger(java.lang.String name)
Detects if a Logger with the specified name exists.- Parameters:
name- The Logger name to search for.- Returns:
- true if the Logger exists, false otherwise.
-
hasLogger
public boolean hasLogger(java.lang.String name, MessageFactory messageFactory)Detects if a Logger with the specified name and MessageFactory exists.- Parameters:
name- The Logger name to search for.messageFactory- The message factory to search for.- Returns:
- true if the Logger exists, false otherwise.
- Since:
- 2.5
-
hasLogger
public boolean hasLogger(java.lang.String name, java.lang.Class<? extends MessageFactory> messageFactoryClass)Detects if a Logger with the specified name and MessageFactory type exists.- Parameters:
name- The Logger name to search for.messageFactoryClass- The message factory class to search for.- Returns:
- true if the Logger exists, false otherwise.
- Since:
- 2.5
-
putIfAbsent
public void putIfAbsent(java.lang.String name, MessageFactory messageFactory, T logger)
-
-