Package org.apache.logging.log4j.spi
Class AbstractLoggerAdapter<L>
java.lang.Object
org.apache.logging.log4j.spi.AbstractLoggerAdapter<L>
- Type Parameters:
- L- the Logger class to adapt
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- LoggerAdapter<L>,- LoggerContextShutdownAware
public abstract class AbstractLoggerAdapter<L>
extends Object
implements LoggerAdapter<L>, LoggerContextShutdownAware
Provides an abstract base class to use for implementing LoggerAdapter.
- Since:
- 2.1
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final Map<LoggerContext,ConcurrentMap<String, L>> A map to store loggers for their given LoggerContexts.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()voidcontextShutdown(LoggerContext loggerContext) protected abstract LoggerContextGets theLoggerContextthat should be used to look up or create loggers.protected LoggerContextgetContext(Class<?> callerClass) Gets theLoggerContextassociated with the given caller class.Gets a named logger.For unit testing.getLoggersInContext(LoggerContext context) Gets or creates the ConcurrentMap of named loggers for a given LoggerContext.protected abstract LnewLogger(String name, LoggerContext context) Creates a new named logger for a givenLoggerContext.
- 
Field Details- 
registryA map to store loggers for their given LoggerContexts.
 
- 
- 
Constructor Details- 
AbstractLoggerAdapterpublic AbstractLoggerAdapter()
 
- 
- 
Method Details- 
getLoggerDescription copied from interface:LoggerAdapterGets a named logger. Implementations should defer to the abstract methods inAbstractLoggerAdapter.- Specified by:
- getLoggerin interface- LoggerAdapter<L>
- Parameters:
- name- the name of the logger to get
- Returns:
- the named logger
 
- 
contextShutdown- Specified by:
- contextShutdownin interface- LoggerContextShutdownAware
 
- 
getLoggersInContextGets or creates the ConcurrentMap of named loggers for a given LoggerContext.- Parameters:
- context- the LoggerContext to get loggers for
- Returns:
- the map of loggers for the given LoggerContext
 
- 
getLoggerContextsFor unit testing. Consider to be private.- Since:
- 2.12.1
 
- 
newLoggerCreates a new named logger for a givenLoggerContext.- Parameters:
- name- the name of the logger to create
- context- the LoggerContext this logger will be associated with
- Returns:
- the new named logger
 
- 
getContextGets theLoggerContextthat should be used to look up or create loggers. This is similar in spirit to theContextSelectorclass inlog4j-core. However, implementations can rely on their own framework's separation of contexts instead (or simply use a singleton).- Returns:
- the LoggerContext to be used for lookup and creation purposes
- See Also:
 
- 
getContextGets theLoggerContextassociated with the given caller class.- Parameters:
- callerClass- the caller class
- Returns:
- the LoggerContext for the calling class
 
- 
closepublic void close()- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
 
 
-