L
- the Logger class to adaptpublic abstract class AbstractLoggerAdapter<L> extends java.lang.Object implements LoggerAdapter<L>, LoggerContextShutdownAware
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.locks.ReadWriteLock |
lock |
protected java.util.Map<LoggerContext,java.util.concurrent.ConcurrentMap<java.lang.String,L>> |
registry
A map to store loggers for their given LoggerContexts.
|
Constructor and Description |
---|
AbstractLoggerAdapter() |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
contextShutdown(LoggerContext loggerContext) |
protected abstract LoggerContext |
getContext()
Gets the
LoggerContext that should be used to look up or create loggers. |
protected LoggerContext |
getContext(java.lang.Class<?> callerClass)
Gets the
LoggerContext associated with the given caller class. |
L |
getLogger(java.lang.String name)
Gets a named logger.
|
java.util.Set<LoggerContext> |
getLoggerContexts()
For unit testing.
|
java.util.concurrent.ConcurrentMap<java.lang.String,L> |
getLoggersInContext(LoggerContext context)
Gets or creates the ConcurrentMap of named loggers for a given LoggerContext.
|
protected abstract L |
newLogger(java.lang.String name,
LoggerContext context)
Creates a new named logger for a given
LoggerContext . |
protected final java.util.Map<LoggerContext,java.util.concurrent.ConcurrentMap<java.lang.String,L>> registry
private final java.util.concurrent.locks.ReadWriteLock lock
public L getLogger(java.lang.String name)
LoggerAdapter
AbstractLoggerAdapter
.getLogger
in interface LoggerAdapter<L>
name
- the name of the logger to getpublic void contextShutdown(LoggerContext loggerContext)
contextShutdown
in interface LoggerContextShutdownAware
public java.util.concurrent.ConcurrentMap<java.lang.String,L> getLoggersInContext(LoggerContext context)
context
- the LoggerContext to get loggers forpublic java.util.Set<LoggerContext> getLoggerContexts()
protected abstract L newLogger(java.lang.String name, LoggerContext context)
LoggerContext
.name
- the name of the logger to createcontext
- the LoggerContext this logger will be associated withprotected abstract LoggerContext getContext()
LoggerContext
that should be used to look up or create loggers. This is similar in spirit to the
ContextSelector
class in log4j-core
. However, implementations can rely on their own framework's
separation of contexts instead (or simply use a singleton).LogManager.getContext(ClassLoader, boolean)
,
LogManager.getContext(String, boolean)
protected LoggerContext getContext(java.lang.Class<?> callerClass)
LoggerContext
associated with the given caller class.callerClass
- the caller classpublic void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable