Top Description Inners Fields Constructors Methods
org.apache.logging.log4j.spi

public Class LoggerRegistry<T extends ExtendedLogger>

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Collection, .Map, .Objects, .WeakHashMap, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, org.apache.logging.log4j.message.MessageFactory

Convenience class to be used by LoggerContext implementations.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
LoggerRegistry.ConcurrentMapFactory<
subtype of ExtendedLogger
T extends ExtendedLogger
>

Generates ConcurrentHashMaps for use by the registry to store the Loggers.

public static interface
LoggerRegistry.MapFactory<
subtype of ExtendedLogger
T extends ExtendedLogger
>

Interface to control the data structure used by the registry to store the Loggers.

public static class
LoggerRegistry.WeakMapFactory<
subtype of ExtendedLogger
T extends ExtendedLogger
>

Generates WeakHashMaps for use by the registry to store the Loggers.

Field Summary

Modifier and TypeField and Description
private static final String
private final LoggerRegistry.MapFactory<T>
private final Map<String, Map<String, T>>

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
private static String
factoryClassKey(final Class<? extends MessageFactory> messageFactoryClass)

private static String
factoryKey(final MessageFactory messageFactory)

public T

Returns:

The logger with the specified name.
getLogger
(final String
The name of the Logger to return.
name
)

Returns an ExtendedLogger.

public T

Returns:

The logger with the specified name.
getLogger
(final String
The name of the Logger to return.
name
,
final 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.
messageFactory
)

Returns an ExtendedLogger.

public Collection<T>
public Collection<T>
getLoggers(final Collection<T> destination)

private Map<String, T>
getOrCreateInnerMap(final String factoryName)

public boolean

Returns:

true if the Logger exists, false otherwise.
hasLogger
(final String
The Logger name to search for.
name
)

Detects if a Logger with the specified name exists.

public boolean

Returns:

true if the Logger exists, false otherwise.
hasLogger
(final String
The Logger name to search for.
name
,
final MessageFactory
The message factory to search for.
messageFactory
)

Detects if a Logger with the specified name and MessageFactory exists.

public boolean

Returns:

true if the Logger exists, false otherwise.
hasLogger
(final String
The Logger name to search for.
name
,
final Class<? extends MessageFactory>
The message factory class to search for.
messageFactoryClass
)

Detects if a Logger with the specified name and MessageFactory type exists.

public void
putIfAbsent(final String name, final MessageFactory messageFactory, final T logger)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_FACTORY_KEYback to summary
private static final String DEFAULT_FACTORY_KEY
factoryback to summary
private final LoggerRegistry.MapFactory<T> factory
mapback to summary
private final Map<String, Map<String, T>> map

Constructor Detail

LoggerRegistryback to summary
public LoggerRegistry()
LoggerRegistryback to summary
public LoggerRegistry(final LoggerRegistry.MapFactory<T> factory)

Method Detail

factoryClassKeyback to summary
private static String factoryClassKey(final Class<? extends MessageFactory> messageFactoryClass)
factoryKeyback to summary
private static String factoryKey(final MessageFactory messageFactory)
getLoggerback to summary
public T getLogger(final String name)

Returns an ExtendedLogger.

Parameters
name:String

The name of the Logger to return.

Returns:T

The logger with the specified name.

getLoggerback to summary
public T getLogger(final String name, final MessageFactory messageFactory)

Returns an ExtendedLogger.

Parameters
name:String

The name of the Logger to return.

messageFactory: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:T

The logger with the specified name.

getLoggersback to summary
public Collection<T> getLoggers()
getLoggersback to summary
public Collection<T> getLoggers(final Collection<T> destination)
getOrCreateInnerMapback to summary
private Map<String, T> getOrCreateInnerMap(final String factoryName)
hasLoggerback to summary
public boolean hasLogger(final String name)

Detects if a Logger with the specified name exists.

Parameters
name:String

The Logger name to search for.

Returns:boolean

true if the Logger exists, false otherwise.

hasLoggerback to summary
public boolean hasLogger(final String name, final MessageFactory messageFactory)

Detects if a Logger with the specified name and MessageFactory exists.

Parameters
name:String

The Logger name to search for.

messageFactory:MessageFactory

The message factory to search for.

Returns:boolean

true if the Logger exists, false otherwise.

Since
2.5
hasLoggerback to summary
public boolean hasLogger(final String name, final Class<? extends MessageFactory> messageFactoryClass)

Detects if a Logger with the specified name and MessageFactory type exists.

Parameters
name:String

The Logger name to search for.

messageFactoryClass:Class<? extends MessageFactory>

The message factory class to search for.

Returns:boolean

true if the Logger exists, false otherwise.

Since
2.5
putIfAbsentback to summary
public void putIfAbsent(final String name, final MessageFactory messageFactory, final T logger)
org.apache.logging.log4j.spi back to summary

public Class LoggerRegistry.ConcurrentMapFactory<T extends ExtendedLogger>

extends Object
implements LoggerRegistry.MapFactory<T extends ExtendedLogger>
Class Inheritance
  • java.lang.Object
  • org.apache.logging.log4j.spi.LoggerRegistry.ConcurrentMapFactory
All Implemented Interfaces
org.apache.logging.log4j.spi.LoggerRegistry.MapFactory
Type Parameters
<T>
subtype of ExtendedLogger

Generates ConcurrentHashMaps for use by the registry to store the Loggers.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Map<String, T>
public Map<String, Map<String, T>>
public void
putIfAbsent(final Map<String, T> innerMap, final String name, final T logger)

Implements org.apache.logging.log4j.spi.LoggerRegistry.MapFactory.putIfAbsent.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ConcurrentMapFactoryback to summary
public ConcurrentMapFactory()

Method Detail

createInnerMapback to summary
public Map<String, T> createInnerMap()

Implements org.apache.logging.log4j.spi.LoggerRegistry.MapFactory.createInnerMap.

Annotations
@Override
createOuterMapback to summary
public Map<String, Map<String, T>> createOuterMap()

Implements org.apache.logging.log4j.spi.LoggerRegistry.MapFactory.createOuterMap.

Annotations
@Override
putIfAbsentback to summary
public void putIfAbsent(final Map<String, T> innerMap, final String name, final T logger)

Implements org.apache.logging.log4j.spi.LoggerRegistry.MapFactory.putIfAbsent.

Annotations
@Override
org.apache.logging.log4j.spi back to summary

public Interface LoggerRegistry.MapFactory<T extends ExtendedLogger>

Known Direct Implementers
org.apache.logging.log4j.spi.LoggerRegistry.ConcurrentMapFactory, org.apache.logging.log4j.spi.LoggerRegistry.WeakMapFactory
Type Parameters
<T>
subtype of ExtendedLogger

Interface to control the data structure used by the registry to store the Loggers.

Method Summary

Modifier and TypeMethod and Description
public Map<String, T>
public Map<String, Map<String, T>>
public void
putIfAbsent(Map<String, T> innerMap, String name, T logger)

Method Detail

createInnerMapback to summary
public Map<String, T> createInnerMap()
createOuterMapback to summary
public Map<String, Map<String, T>> createOuterMap()
putIfAbsentback to summary
public void putIfAbsent(Map<String, T> innerMap, String name, T logger)
org.apache.logging.log4j.spi back to summary

public Class LoggerRegistry.WeakMapFactory<T extends ExtendedLogger>

extends Object
implements LoggerRegistry.MapFactory<T extends ExtendedLogger>
Class Inheritance
All Implemented Interfaces
org.apache.logging.log4j.spi.LoggerRegistry.MapFactory
Type Parameters
<T>
subtype of ExtendedLogger

Generates WeakHashMaps for use by the registry to store the Loggers.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Map<String, T>
public Map<String, Map<String, T>>
public void
putIfAbsent(final Map<String, T> innerMap, final String name, final T logger)

Implements org.apache.logging.log4j.spi.LoggerRegistry.MapFactory.putIfAbsent.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

WeakMapFactoryback to summary
public WeakMapFactory()

Method Detail

createInnerMapback to summary
public Map<String, T> createInnerMap()

Implements org.apache.logging.log4j.spi.LoggerRegistry.MapFactory.createInnerMap.

Annotations
@Override
createOuterMapback to summary
public Map<String, Map<String, T>> createOuterMap()

Implements org.apache.logging.log4j.spi.LoggerRegistry.MapFactory.createOuterMap.

Annotations
@Override
putIfAbsentback to summary
public void putIfAbsent(final Map<String, T> innerMap, final String name, final T logger)

Implements org.apache.logging.log4j.spi.LoggerRegistry.MapFactory.putIfAbsent.

Annotations
@Override