Class LoggerRegistry<T extends ExtendedLogger>
- java.lang.Object
-
- org.apache.logging.log4j.spi.LoggerRegistry<T>
-
@NullMarked public class LoggerRegistry<T extends ExtendedLogger> extends Object
Convenience class to be used as anExtendedLoggerregistry byLoggerContextimplementations.- Since:
- 2.6
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLoggerRegistry.ConcurrentMapFactory<T extends ExtendedLogger>Deprecated.As of version2.25.0, planned to be removed!static interfaceLoggerRegistry.MapFactory<T extends ExtendedLogger>Deprecated.As of version2.25.0, planned to be removed!static classLoggerRegistry.WeakMapFactory<T extends ExtendedLogger>Deprecated.As of version2.25.0, planned to be removed!
-
Constructor Summary
Constructors Constructor Description LoggerRegistry()LoggerRegistry(@Nullable LoggerRegistry.MapFactory<T> mapFactory)Deprecated.As of version2.25.0, planned to be removed!
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description @Nullable TgetLogger(String name)Deprecated.As of version2.25.0, planned to be removed!@Nullable TgetLogger(String name, @Nullable MessageFactory messageFactory)Returns the logger associated with the given name and message factory.Collection<T>getLoggers()Collection<T>getLoggers(Collection<T> destination)booleanhasLogger(String name)Deprecated.As of version2.25.0, planned to be removed!booleanhasLogger(String name, @Nullable MessageFactory messageFactory)Checks if a logger associated with the given name and message factory exists.booleanhasLogger(String name, Class<? extends MessageFactory> messageFactoryClass)Checks if a logger associated with the given name and message factory type exists.voidputIfAbsent(String name, @Nullable MessageFactory messageFactory, T logger)Registers the provided logger.
-
-
-
Constructor Detail
-
LoggerRegistry
public LoggerRegistry()
-
LoggerRegistry
@Deprecated public LoggerRegistry(@Nullable LoggerRegistry.MapFactory<T> mapFactory)
Deprecated.As of version2.25.0, planned to be removed!Constructs an instance ignoring the given the map factory.- Parameters:
mapFactory- a map factory
-
-
Method Detail
-
getLogger
@Deprecated public @Nullable T getLogger(String name)
Deprecated.As of version2.25.0, planned to be removed! UsegetLogger(String, MessageFactory)instead.Returns the logger associated with the given name.There can be made no assumptions on the message factory of the returned logger. Callers are strongly advised to switch to
getLogger(String, MessageFactory)and provide a message factory parameter!- Parameters:
name- a logger name- Returns:
- the logger associated with the name
-
getLogger
public @Nullable T getLogger(String name, @Nullable MessageFactory messageFactory)
Returns the logger associated with the given name and message factory.In the absence of a message factory, there can be made no assumptions on the message factory of the returned logger. This lenient behaviour is only kept for backward compatibility. Callers are strongly advised to provide a message factory parameter to the method!
- Parameters:
name- a logger namemessageFactory- a message factory- Returns:
- the logger associated with the given name and message factory
-
getLoggers
public Collection<T> getLoggers()
-
getLoggers
public Collection<T> getLoggers(Collection<T> destination)
-
hasLogger
@Deprecated public boolean hasLogger(String name)
Deprecated.As of version2.25.0, planned to be removed! UsehasLogger(String, MessageFactory)instead.Checks if a logger associated with the given name exists.There can be made no assumptions on the message factory of the found logger. Callers are strongly advised to switch to
hasLogger(String, MessageFactory)and provide a message factory parameter!- Parameters:
name- a logger name- Returns:
true, if the logger exists;falseotherwise.
-
hasLogger
public boolean hasLogger(String name, @Nullable MessageFactory messageFactory)
Checks if a logger associated with the given name and message factory exists.In the absence of a message factory, there can be made no assumptions on the message factory of the found logger. This lenient behaviour is only kept for backward compatibility. Callers are strongly advised to provide a message factory parameter to the method!
- Parameters:
name- a logger namemessageFactory- a message factory- Returns:
true, if the logger exists;falseotherwise.- Since:
- 2.5
-
hasLogger
public boolean hasLogger(String name, Class<? extends MessageFactory> messageFactoryClass)
Checks if a logger associated with the given name and message factory type exists.- Parameters:
name- a logger namemessageFactoryClass- a message factory class- Returns:
true, if the logger exists;falseotherwise.- Since:
- 2.5
-
putIfAbsent
public void putIfAbsent(String name, @Nullable MessageFactory messageFactory, T logger)
Registers the provided logger.The logger will be registered using the keys provided by the
nameandmessageFactoryparameters and the values ofLogger.getName()andLogger.getMessageFactory().- Parameters:
name- a logger namemessageFactory- a message factorylogger- a logger instance
-
-