public abstract class AbstractConfiguration extends AbstractFilterable implements Configuration
AbstractFilterable.Builder<B extends AbstractFilterable.Builder<B>>
LifeCycle.State
Modifier and Type | Field and Description |
---|---|
protected boolean |
isShutdownHookEnabled
Shutdown hook is enabled by default.
|
protected List<ConfigurationListener> |
listeners
Listeners for configuration changes.
|
protected PluginManager |
pluginManager
The plugin manager.
|
protected List<String> |
pluginPackages
Packages found in configuration "packages" attribute.
|
protected Node |
rootNode
The root node of the configuration.
|
protected ScriptManager |
scriptManager
The Script manager.
|
protected long |
shutdownTimeoutMillis
Shutdown timeout in milliseconds.
|
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
CONTEXT_PROPERTIES
Modifier | Constructor and Description |
---|---|
protected |
AbstractConfiguration(LoggerContext loggerContext,
ConfigurationSource configurationSource)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addAppender(Appender appender)
Adds an Appender to the configuration.
|
void |
addComponent(String componentName,
Object obj) |
void |
addListener(ConfigurationListener listener)
Add a listener for changes on the configuration.
|
void |
addLogger(String loggerName,
LoggerConfig loggerConfig)
Add a loggerConfig.
|
void |
addLoggerAppender(Logger logger,
Appender appender)
Associates an Appender with a LoggerConfig.
|
void |
addLoggerFilter(Logger logger,
Filter filter)
Associates a Filter with a LoggerConfig.
|
protected void |
createAdvertiser(String advertiserString,
ConfigurationSource configSource,
byte[] buffer,
String contentType) |
void |
createConfiguration(Node node,
LogEvent event) |
Object |
createPluginObject(PluginType<?> type,
Node node)
This method is used by Arbiters to create specific children.
|
protected void |
doConfigure() |
Advertiser |
getAdvertiser() |
<T extends Appender> |
getAppender(String appenderName)
Returns the Appender with the specified name.
|
Map<String,Appender> |
getAppenders()
Returns a Map containing all the Appenders and their name.
|
AsyncLoggerConfigDelegate |
getAsyncLoggerConfigDelegate()
Returns the
AsyncLoggerConfigDelegate shared by all
AsyncLoggerConfig instances defined in this Configuration. |
<T> T |
getComponent(String componentName) |
ConfigurationSource |
getConfigurationSource()
Returns the source of this configuration.
|
StrSubstitutor |
getConfigurationStrSubstitutor() |
List<CustomLevelConfig> |
getCustomLevels()
Returns a list of descriptors of the custom levels defined in the current configuration.
|
protected org.apache.logging.log4j.Level |
getDefaultStatus() |
LoggerConfig |
getLogger(String loggerName)
Returns the LoggerConfig with the specified name.
|
LoggerConfig |
getLoggerConfig(String loggerName)
Locates the appropriate LoggerConfig for a Logger name.
|
LoggerContext |
getLoggerContext()
Gets the logger context.
|
Map<String,LoggerConfig> |
getLoggers()
Returns a Map of all the LoggerConfigs.
|
String |
getName()
Returns the name of the configuration.
|
NanoClock |
getNanoClock()
Returns the
NanoClock instance for this configuration. |
PluginManager |
getPluginManager() |
List<String> |
getPluginPackages()
Returns the list of packages to scan for plugins for this Configuration.
|
Map<String,String> |
getProperties() |
ReliabilityStrategy |
getReliabilityStrategy(LoggerConfig loggerConfig) |
LoggerConfig |
getRootLogger()
Returns the root Logger.
|
Node |
getRootNode() |
ConfigurationScheduler |
getScheduler() |
ScriptManager |
getScriptManager() |
long |
getShutdownTimeoutMillis() |
StrSubstitutor |
getStrSubstitutor() |
WatchManager |
getWatchManager()
Return the WatchManager.
|
void |
initialize()
Initialize the configuration.
|
protected void |
initializeWatchers(Reconfigurable reconfigurable,
ConfigurationSource configSource,
int monitorIntervalSeconds) |
boolean |
isShutdownHookEnabled() |
protected void |
preConfigure(Node node) |
protected void |
processConditionals(Node node)
Process conditions by evaluating them and including the children of conditions that are true
and discarding those that are not.
|
protected List<Node> |
processSelect(Node selectNode,
PluginType<?> type)
Handle Select nodes.
|
void |
removeAppender(String appenderName)
Remove an Appender.
|
void |
removeListener(ConfigurationListener listener)
Remove a ConfigurationListener.
|
void |
removeLogger(String loggerName)
Remove a LoggerConfig.
|
void |
setAdvertiser(Advertiser advertiser) |
void |
setLoggerAdditive(Logger logger,
boolean additive)
Marks a LoggerConfig as additive.
|
void |
setName(String name)
Set the name of the configuration.
|
void |
setNanoClock(NanoClock nanoClock)
Sets the
NanoClock instance for this configuration. |
void |
setPluginManager(PluginManager pluginManager) |
void |
setScriptManager(ScriptManager scriptManager) |
protected void |
setToDefault() |
void |
setup() |
void |
start()
Start the configuration.
|
boolean |
stop(long timeout,
TimeUnit timeUnit)
Tear down the configuration.
|
protected static byte[] |
toByteArray(InputStream is)
Reads an InputStream using buffered reads into a byte array buffer.
|
addFilter, getFilter, getPropertyArray, hasFilter, isFiltered, removeFilter, stop
equalsImpl, getState, getStatusLogger, hashCodeImpl, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, stop, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addFilter, getFilter, hasFilter, isFiltered, removeFilter
protected final List<ConfigurationListener> listeners
protected final List<String> pluginPackages
protected PluginManager pluginManager
protected boolean isShutdownHookEnabled
protected long shutdownTimeoutMillis
protected ScriptManager scriptManager
protected AbstractConfiguration(LoggerContext loggerContext, ConfigurationSource configurationSource)
public ConfigurationSource getConfigurationSource()
Configuration
getConfigurationSource
in interface Configuration
null
, but may be
ConfigurationSource.NULL_SOURCE
or
ConfigurationSource.COMPOSITE_SOURCE
public List<String> getPluginPackages()
Configuration
getPluginPackages
in interface Configuration
public Map<String,String> getProperties()
getProperties
in interface Configuration
public ScriptManager getScriptManager()
getScriptManager
in interface Configuration
public void setScriptManager(ScriptManager scriptManager)
public PluginManager getPluginManager()
public void setPluginManager(PluginManager pluginManager)
public WatchManager getWatchManager()
Configuration
getWatchManager
in interface Configuration
public ConfigurationScheduler getScheduler()
getScheduler
in interface Configuration
public Node getRootNode()
public AsyncLoggerConfigDelegate getAsyncLoggerConfigDelegate()
Configuration
AsyncLoggerConfigDelegate
shared by all
AsyncLoggerConfig
instances defined in this Configuration.getAsyncLoggerConfigDelegate
in interface Configuration
AsyncLoggerConfigDelegate
public void initialize()
initialize
in interface LifeCycle
initialize
in class AbstractLifeCycle
protected void initializeWatchers(Reconfigurable reconfigurable, ConfigurationSource configSource, int monitorIntervalSeconds)
public void start()
start
in interface LifeCycle
start
in class AbstractFilterable
public boolean stop(long timeout, TimeUnit timeUnit)
stop
in interface LifeCycle2
stop
in class AbstractFilterable
timeout
- the maximum time to waittimeUnit
- the time unit of the timeout argumentpublic boolean isShutdownHookEnabled()
isShutdownHookEnabled
in interface Configuration
public long getShutdownTimeoutMillis()
getShutdownTimeoutMillis
in interface Configuration
public void setup()
protected org.apache.logging.log4j.Level getDefaultStatus()
protected void createAdvertiser(String advertiserString, ConfigurationSource configSource, byte[] buffer, String contentType)
public <T> T getComponent(String componentName)
getComponent
in interface Configuration
public void addComponent(String componentName, Object obj)
addComponent
in interface Configuration
protected void preConfigure(Node node)
protected void processConditionals(Node node)
node
- The node to evaluate.protected List<Node> processSelect(Node selectNode, PluginType<?> type)
selectNode
- The Select Node.type
- The PluginType of the Select Node.protected void doConfigure()
protected void setToDefault()
public void setName(String name)
name
- The name.public String getName()
getName
in interface Configuration
public void addListener(ConfigurationListener listener)
addListener
in interface Configuration
listener
- The ConfigurationListener to add.public void removeListener(ConfigurationListener listener)
removeListener
in interface Configuration
listener
- The ConfigurationListener to remove.public <T extends Appender> T getAppender(String appenderName)
getAppender
in interface Configuration
T
- The expected Appender type.appenderName
- The name of the Appender.public Map<String,Appender> getAppenders()
getAppenders
in interface Configuration
public void addAppender(Appender appender)
addAppender
in interface Configuration
appender
- The Appender to add.public StrSubstitutor getStrSubstitutor()
getStrSubstitutor
in interface Configuration
public StrSubstitutor getConfigurationStrSubstitutor()
getConfigurationStrSubstitutor
in interface Configuration
public void setAdvertiser(Advertiser advertiser)
setAdvertiser
in interface Configuration
public Advertiser getAdvertiser()
getAdvertiser
in interface Configuration
public ReliabilityStrategy getReliabilityStrategy(LoggerConfig loggerConfig)
getReliabilityStrategy
in interface Configuration
public void addLoggerAppender(Logger logger, Appender appender)
addLoggerAppender
in interface Configuration
logger
- The Logger the Appender will be associated with.appender
- The Appender.public void addLoggerFilter(Logger logger, Filter filter)
addLoggerFilter
in interface Configuration
logger
- The Logger the Footer will be associated with.filter
- The Filter.public void setLoggerAdditive(Logger logger, boolean additive)
setLoggerAdditive
in interface Configuration
logger
- The Logger the Appender will be associated with.additive
- True if the LoggerConfig should be additive, false otherwise.public void removeAppender(String appenderName)
appenderName
- the name of the appender to remove.public List<CustomLevelConfig> getCustomLevels()
Configuration
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}.
getCustomLevels
in interface Configuration
public LoggerConfig getLoggerConfig(String loggerName)
getLoggerConfig
in interface Configuration
loggerName
- The Logger name.public LoggerContext getLoggerContext()
Configuration
getLoggerContext
in interface Configuration
public LoggerConfig getRootLogger()
getRootLogger
in interface Configuration
public Map<String,LoggerConfig> getLoggers()
getLoggers
in interface Configuration
public LoggerConfig getLogger(String loggerName)
loggerName
- The Logger name.public void addLogger(String loggerName, LoggerConfig loggerConfig)
addLogger
in interface Configuration
loggerName
- The name of the Logger.loggerConfig
- The LoggerConfig.public void removeLogger(String loggerName)
removeLogger
in interface Configuration
loggerName
- The name of the Logger.public void createConfiguration(Node node, LogEvent event)
createConfiguration
in interface Configuration
public Object createPluginObject(PluginType<?> type, Node node)
type
- The PluginType.node
- The Node.protected static byte[] toByteArray(InputStream is) throws IOException
is
- the InputStream to read into a byte array buffer.IOException
- if the read
method of the provided InputStream throws this exception.public NanoClock getNanoClock()
Configuration
NanoClock
instance for this configuration.getNanoClock
in interface Configuration
public void setNanoClock(NanoClock nanoClock)
Configuration
NanoClock
instance for this configuration.setNanoClock
in interface Configuration
nanoClock
- the new nano clock for this configuration. Must be non-null.Copyright © 1999-2020 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.