Package ch.qos.logback.classic
Class LoggerContext
- java.lang.Object
-
- ch.qos.logback.core.ContextBase
-
- ch.qos.logback.classic.LoggerContext
-
- All Implemented Interfaces:
Context
,LifeCycle
,PropertyContainer
,ILoggerFactory
public class LoggerContext extends ContextBase implements ILoggerFactory, LifeCycle
LoggerContext glues many of the logback-classic components together. In principle, every logback-classic component instance is attached either directly or indirectly to a LoggerContext instance. Just as importantly LoggerContext implements theILoggerFactory
acting as the manufacturing source ofLogger
instances.
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEFAULT_PACKAGING_DATA
Default setting of packaging data in stack traces
-
Constructor Summary
Constructors Constructor Description LoggerContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(LoggerContextListener listener)
void
addTurboFilter(TurboFilter newFilter)
Logger
exists(java.lang.String name)
Check if the named logger exists in the hierarchy.java.util.List<LoggerContextListener>
getCopyOfListenerList()
java.util.List<java.lang.String>
getFrameworkPackages()
List of packages considered part of the logging framework such that they are never considered as callers of the logging framework.Logger
getLogger(java.lang.Class<?> clazz)
Logger
getLogger(java.lang.String name)
Return an appropriateLogger
instance as specified by thename
parameter.LoggerContextVO
getLoggerContextRemoteView()
java.util.List<Logger>
getLoggerList()
int
getMaxCallerDataDepth()
TurboFilterList
getTurboFilterList()
boolean
isPackagingDataEnabled()
void
putProperty(java.lang.String key, java.lang.String val)
Set a property of this context.void
removeListener(LoggerContextListener listener)
void
reset()
This method clears all internal properties, except internal status messages, closes all appenders, removes any turboFilters, fires an OnReset event, removes all status listeners, removes all context listeners (except those which are reset resistant).void
resetTurboFilterList()
First processPriorToRemoval all registered turbo filters and then clear the registration list.void
setMaxCallerDataDepth(int maxCallerDataDepth)
void
setName(java.lang.String name)
The context name can be set only if it is not already set, or if the current name is the default context name, namely "default", or if the current name and the old name are the same.void
setPackagingDataEnabled(boolean packagingDataEnabled)
void
start()
void
stop()
java.lang.String
toString()
-
Methods inherited from class ch.qos.logback.core.ContextBase
addScheduledFuture, getBirthTime, getConfigurationLock, getCopyOfPropertyMap, getExecutorService, getName, getObject, getProperty, getScheduledExecutorService, getScheduledFutures, getStatusManager, isStarted, putObject, register, removeObject, setStatusManager
-
-
-
-
Field Detail
-
DEFAULT_PACKAGING_DATA
public static final boolean DEFAULT_PACKAGING_DATA
Default setting of packaging data in stack traces- See Also:
- Constant Field Values
-
-
Method Detail
-
putProperty
public void putProperty(java.lang.String key, java.lang.String val)
Description copied from interface:Context
Set a property of this context.- Specified by:
putProperty
in interfaceContext
- Overrides:
putProperty
in classContextBase
-
setName
public void setName(java.lang.String name)
Description copied from class:ContextBase
The context name can be set only if it is not already set, or if the current name is the default context name, namely "default", or if the current name and the old name are the same.- Specified by:
setName
in interfaceContext
- Overrides:
setName
in classContextBase
-
getLogger
public final Logger getLogger(java.lang.Class<?> clazz)
-
getLogger
public final Logger getLogger(java.lang.String name)
Description copied from interface:ILoggerFactory
Return an appropriateLogger
instance as specified by thename
parameter.If the name parameter is equal to
Logger.ROOT_LOGGER_NAME
, that is the string value "ROOT" (case insensitive), then the root logger of the underlying logging system is returned.Null-valued name arguments are considered invalid.
Certain extremely simple logging systems, e.g. NOP, may always return the same logger instance regardless of the requested name.
- Specified by:
getLogger
in interfaceILoggerFactory
- Parameters:
name
- the name of the Logger to return- Returns:
- a Logger instance
-
exists
public Logger exists(java.lang.String name)
Check if the named logger exists in the hierarchy. If so return its reference, otherwise returnsnull
.- Parameters:
name
- the name of the logger to search for.
-
getLoggerList
public java.util.List<Logger> getLoggerList()
-
getLoggerContextRemoteView
public LoggerContextVO getLoggerContextRemoteView()
-
setPackagingDataEnabled
public void setPackagingDataEnabled(boolean packagingDataEnabled)
-
isPackagingDataEnabled
public boolean isPackagingDataEnabled()
-
reset
public void reset()
This method clears all internal properties, except internal status messages, closes all appenders, removes any turboFilters, fires an OnReset event, removes all status listeners, removes all context listeners (except those which are reset resistant). As mentioned above, internal status messages survive resets.- Overrides:
reset
in classContextBase
-
getTurboFilterList
public TurboFilterList getTurboFilterList()
-
addTurboFilter
public void addTurboFilter(TurboFilter newFilter)
-
resetTurboFilterList
public void resetTurboFilterList()
First processPriorToRemoval all registered turbo filters and then clear the registration list.
-
addListener
public void addListener(LoggerContextListener listener)
-
removeListener
public void removeListener(LoggerContextListener listener)
-
getCopyOfListenerList
public java.util.List<LoggerContextListener> getCopyOfListenerList()
-
start
public void start()
- Specified by:
start
in interfaceLifeCycle
- Overrides:
start
in classContextBase
-
stop
public void stop()
- Specified by:
stop
in interfaceLifeCycle
- Overrides:
stop
in classContextBase
-
toString
public java.lang.String toString()
- Overrides:
toString
in classContextBase
-
getMaxCallerDataDepth
public int getMaxCallerDataDepth()
-
setMaxCallerDataDepth
public void setMaxCallerDataDepth(int maxCallerDataDepth)
-
getFrameworkPackages
public java.util.List<java.lang.String> getFrameworkPackages()
List of packages considered part of the logging framework such that they are never considered as callers of the logging framework. This list used to compute the caller for logging events. To designate package "com.foo" as well as all its subpackages as being part of the logging framework, simply add "com.foo" to this list.- Returns:
- list of framework packages
-
-