Interface Configuration
-
- All Superinterfaces:
Filterable,LifeCycle
- All Known Implementing Classes:
AbstractConfiguration,BuiltConfiguration,CompositeConfiguration,DefaultConfiguration,JsonConfiguration,NullConfiguration,PropertiesConfiguration,XmlConfiguration,YamlConfiguration
public interface Configuration extends Filterable
Interface that must be implemented to create a configuration.Custom implementations are recommended to extend
AbstractConfiguration.- See Also:
AbstractConfiguration,LifeCycle2
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle
LifeCycle.State
-
-
Field Summary
Fields Modifier and Type Field Description static StringCONTEXT_PROPERTIESKey for storing the Context properties.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddAppender(Appender appender)voidaddComponent(String name, Object object)voidaddListener(ConfigurationListener listener)voidaddLogger(String name, LoggerConfig loggerConfig)voidaddLoggerAppender(Logger logger, Appender appender)voidaddLoggerFilter(Logger logger, Filter filter)voidcreateConfiguration(Node node, LogEvent event)AdvertisergetAdvertiser()<T extends Appender>
TgetAppender(String name)Returns the Appender with the specified name.Map<String,Appender>getAppenders()Returns a Map containing all the Appenders and their name.AsyncLoggerConfigDelegategetAsyncLoggerConfigDelegate()Returns theAsyncLoggerConfigDelegateshared by allAsyncLoggerConfiginstances defined in this Configuration.AsyncWaitStrategyFactorygetAsyncWaitStrategyFactory()Returns theAsyncWaitStrategyFactorydefined in this Configuration; this factory is used to create the LMAX disruptorWaitStrategyused by the disruptor ringbuffer for Async Loggers.<T> TgetComponent(String name)ConfigurationSourcegetConfigurationSource()Returns the source of this configuration.default StrSubstitutorgetConfigurationStrSubstitutor()List<CustomLevelConfig>getCustomLevels()Returns a list of descriptors of the custom levels defined in the current configuration.LoggerConfiggetLoggerConfig(String name)Locates the appropriate LoggerConfig for a Logger name.LoggerContextgetLoggerContext()Gets the logger context.Map<String,LoggerConfig>getLoggers()StringgetName()Returns the configuration name.NanoClockgetNanoClock()Returns theNanoClockinstance for this configuration.List<String>getPluginPackages()Returns the list of packages to scan for plugins for this Configuration.Map<String,String>getProperties()ReliabilityStrategygetReliabilityStrategy(LoggerConfig loggerConfig)LoggerConfiggetRootLogger()Returns the root Logger.ConfigurationSchedulergetScheduler()ScriptManagergetScriptManager()longgetShutdownTimeoutMillis()StrSubstitutorgetStrSubstitutor()WatchManagergetWatchManager()Return the WatchManager.booleanisShutdownHookEnabled()voidremoveListener(ConfigurationListener listener)voidremoveLogger(String name)voidsetAdvertiser(Advertiser advertiser)voidsetLoggerAdditive(Logger logger, boolean additive)voidsetNanoClock(NanoClock nanoClock)Sets theNanoClockinstance for this configuration.-
Methods inherited from interface org.apache.logging.log4j.core.filter.Filterable
addFilter, getFilter, hasFilter, isFiltered, removeFilter
-
-
-
-
Field Detail
-
CONTEXT_PROPERTIES
static final String CONTEXT_PROPERTIES
Key for storing the Context properties.- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
String getName()
Returns the configuration name.- Returns:
- the name of the configuration.
-
getLoggerConfig
LoggerConfig getLoggerConfig(String name)
Locates the appropriate LoggerConfig for a Logger name. This will remove tokens from the package name as necessary or return the root LoggerConfig if no other matches were found.- Parameters:
name- The Logger name.- Returns:
- The located LoggerConfig.
-
getAppender
<T extends Appender> T getAppender(String name)
Returns the Appender with the specified name.- Type Parameters:
T- The expected Appender type.- Parameters:
name- The name of the Appender.- Returns:
- the Appender with the specified name or null if the Appender cannot be located.
-
getAppenders
Map<String,Appender> getAppenders()
Returns a Map containing all the Appenders and their name.- Returns:
- A Map containing each Appender's name and the Appender object.
-
addAppender
void addAppender(Appender appender)
-
getLoggers
Map<String,LoggerConfig> getLoggers()
-
setLoggerAdditive
void setLoggerAdditive(Logger logger, boolean additive)
-
addLogger
void addLogger(String name, LoggerConfig loggerConfig)
-
removeLogger
void removeLogger(String name)
-
getPluginPackages
List<String> getPluginPackages()
Returns the list of packages to scan for plugins for this Configuration.- Returns:
- the list of plugin packages.
- Since:
- 2.1
-
getRootLogger
LoggerConfig getRootLogger()
Returns the root Logger.- Returns:
- the root Logger.
-
addListener
void addListener(ConfigurationListener listener)
-
removeListener
void removeListener(ConfigurationListener listener)
-
getStrSubstitutor
StrSubstitutor getStrSubstitutor()
-
getConfigurationStrSubstitutor
default StrSubstitutor getConfigurationStrSubstitutor()
-
getComponent
<T> T getComponent(String name)
-
setAdvertiser
void setAdvertiser(Advertiser advertiser)
-
getAdvertiser
Advertiser getAdvertiser()
-
isShutdownHookEnabled
boolean isShutdownHookEnabled()
-
getShutdownTimeoutMillis
long getShutdownTimeoutMillis()
-
getScheduler
ConfigurationScheduler getScheduler()
-
getConfigurationSource
ConfigurationSource getConfigurationSource()
Returns the source of this configuration.- Returns:
- the source of this configuration, never
null, but may beConfigurationSource.NULL_SOURCEorConfigurationSource.COMPOSITE_SOURCE
-
getCustomLevels
List<CustomLevelConfig> getCustomLevels()
Returns a list of descriptors of the custom levels defined in the current configuration. The returned list does not include custom levels that are defined in code with direct calls to
Level.forName(String, int).Note that the list does not include levels of previous configurations. For example, suppose a configuration contains custom levels A, B and C. The configuration is then modified to contain custom levels B, C and D. For the new configuration, this method will return only {B, C, D}, that is, only the custom levels defined in this configuration. The previously defined level A still exists (and can be obtained with
Level.getLevel(String)), it is just not in the current configuration.Level.values()will return {A, B, C, D and the built-in levels}.- Returns:
- the custom levels defined in the current configuration
-
getScriptManager
ScriptManager getScriptManager()
-
getAsyncLoggerConfigDelegate
AsyncLoggerConfigDelegate getAsyncLoggerConfigDelegate()
Returns theAsyncLoggerConfigDelegateshared by allAsyncLoggerConfiginstances defined in this Configuration.- Returns:
- the
AsyncLoggerConfigDelegate
-
getAsyncWaitStrategyFactory
AsyncWaitStrategyFactory getAsyncWaitStrategyFactory()
Returns theAsyncWaitStrategyFactorydefined in this Configuration; this factory is used to create the LMAX disruptorWaitStrategyused by the disruptor ringbuffer for Async Loggers.- Returns:
- the
AsyncWaitStrategyFactory - Since:
- 2.17.3
-
getWatchManager
WatchManager getWatchManager()
Return the WatchManager.- Returns:
- the WatchManager.
-
getReliabilityStrategy
ReliabilityStrategy getReliabilityStrategy(LoggerConfig loggerConfig)
-
getNanoClock
NanoClock getNanoClock()
Returns theNanoClockinstance for this configuration.- Returns:
- the nano clock
-
setNanoClock
void setNanoClock(NanoClock nanoClock)
Sets theNanoClockinstance for this configuration.- Parameters:
nanoClock- the new nano clock for this configuration. Must be non-null.
-
getLoggerContext
LoggerContext getLoggerContext()
Gets the logger context.- Returns:
- the logger context.
-
-