Class InternalLoggerRegistry


  • @NullMarked
    public final class InternalLoggerRegistry
    extends Object
    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
    • Constructor Detail

      • InternalLoggerRegistry

        public InternalLoggerRegistry()
    • Method Detail

      • getLogger

        public @Nullable Logger getLogger​(String name,
                                          MessageFactory messageFactory)
        Returns the logger associated with the given name and message factory.
        Parameters:
        name - a logger name
        messageFactory - a message factory
        Returns:
        the logger associated with the given name and message factory
      • hasLogger

        public boolean hasLogger​(String name,
                                 MessageFactory messageFactory)
        Checks if a logger associated with the given name and message factory exists.
        Parameters:
        name - a logger name
        messageFactory - a message factory
        Returns:
        true, if the logger exists; false otherwise.
      • 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 name
        messageFactoryClass - a message factory class
        Returns:
        true, if the logger exists; false otherwise.