Class InternalLoggerRegistry
java.lang.Object
org.apache.logging.log4j.core.util.internal.InternalLoggerRegistry
A registry of
Loggers namespaced by name and message factory.
This class is internally used by LoggerContext.
We don't use the registry from Log4j API to keep Log4j Core independent from the version of Log4j API at runtime. This also allows Log4j Core to evolve independently from Log4j API.
- Since:
- 2.25.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ReadWriteLockprivate final Map<MessageFactory, Map<String, WeakReference<Logger>>> private final Lockprivate final ReferenceQueue<Logger> private final Lock -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncomputeIfAbsent(String name, MessageFactory messageFactory, BiFunction<String, MessageFactory, Logger> loggerSupplier) private voidExpunges stale entries for logger references and message factories.@Nullable LoggergetLogger(String name, MessageFactory messageFactory) Returns the logger associated with the given name and message factory.booleanhasLogger(String name, Class<? extends MessageFactory> messageFactoryClass) Checks if a logger associated with the given name and message factory type exists.booleanhasLogger(String name, MessageFactory messageFactory) Checks if a logger associated with the given name and message factory exists.
-
Field Details
-
loggerRefByNameByMessageFactory
-
lock
-
readLock
-
writeLock
-
staleLoggerRefs
-
-
Constructor Details
-
InternalLoggerRegistry
public InternalLoggerRegistry()
-
-
Method Details
-
expungeStaleEntries
private void expungeStaleEntries()Expunges stale entries for logger references and message factories. -
getLogger
Returns the logger associated with the given name and message factory.- Parameters:
name- a logger namemessageFactory- a message factory- Returns:
- the logger associated with the given name and message factory
-
getLoggers
-
hasLogger
Checks if a logger associated with the given name and message factory exists.- Parameters:
name- a logger namemessageFactory- a message factory- Returns:
true, if the logger exists;falseotherwise.
-
hasLogger
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.
-
computeIfAbsent
public Logger computeIfAbsent(String name, MessageFactory messageFactory, BiFunction<String, MessageFactory, Logger> loggerSupplier)
-