L
- the Logger class to adaptpublic abstract class AbstractLoggerAdapter<L> extends Object implements LoggerAdapter<L>, LoggerContextShutdownAware
Modifier and Type | Field and Description |
---|---|
protected Map<LoggerContext,ConcurrentMap<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(Class<?> callerClass)
Gets the
LoggerContext associated with the given caller class. |
L |
getLogger(String name)
Gets a named logger.
|
Set<LoggerContext> |
getLoggerContexts()
For unit testing.
|
ConcurrentMap<String,L> |
getLoggersInContext(LoggerContext context)
Gets or creates the ConcurrentMap of named loggers for a given LoggerContext.
|
protected abstract L |
newLogger(String name,
LoggerContext context)
Creates a new named logger for a given
LoggerContext . |
protected final Map<LoggerContext,ConcurrentMap<String,L>> registry
public AbstractLoggerAdapter()
public L getLogger(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 ConcurrentMap<String,L> getLoggersInContext(LoggerContext context)
context
- the LoggerContext to get loggers forpublic Set<LoggerContext> getLoggerContexts()
protected abstract L newLogger(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(Class<?> callerClass)
LoggerContext
associated with the given caller class.callerClass
- the caller classpublic void close()
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 1999-1969 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.