public abstract class AbstractConfiguration extends AbstractFilterable implements Configuration
LifeCycle.State| Modifier and Type | Field and Description |
|---|---|
protected boolean |
isShutdownHookEnabled |
protected List<ConfigurationListener> |
listeners
Listeners for configuration changes.
|
protected ConfigurationMonitor |
monitor
The ConfigurationMonitor that checks for configuration changes.
|
protected PluginManager |
pluginManager |
protected List<String> |
pluginPackages |
protected Node |
rootNode
The root node of the configuration.
|
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGERCONTEXT_PROPERTIES| Modifier | Constructor and Description |
|---|---|
protected |
AbstractConfiguration(ConfigurationSource configurationSource)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAppender(Appender appender)
Adds an Appender to the configuration.
|
void |
addComponent(String name,
Object obj) |
void |
addListener(ConfigurationListener listener)
Add a listener for changes on the configuration.
|
void |
addLogger(String name,
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) |
protected void |
doConfigure() |
Advertiser |
getAdvertiser() |
Appender |
getAppender(String name)
Returns the Appender with the specified name.
|
Map<String,Appender> |
getAppenders()
Returns a Map containing all the Appenders and their name.
|
<T> T |
getComponent(String name) |
ConfigurationMonitor |
getConfigurationMonitor() |
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 Level |
getDefaultStatus() |
LoggerConfig |
getLogger(String name)
Returns the LoggerConfig with the specified name.
|
LoggerConfig |
getLoggerConfig(String name)
Locates the appropriate LoggerConfig for a Logger name.
|
Map<String,LoggerConfig> |
getLoggers()
Returns a Map of all the LoggerConfigs.
|
String |
getName()
Returns the name of the configuration.
|
List<String> |
getPluginPackages()
Returns the list of packages to scan for plugins for this Configuration.
|
Map<String,String> |
getProperties() |
LoggerConfig |
getRootLogger()
Returns the root Logger.
|
StrSubstitutor |
getStrSubstitutor() |
boolean |
isShutdownHookEnabled() |
void |
removeAppender(String name)
Remove an Appender.
|
void |
removeListener(ConfigurationListener listener)
Remove a ConfigurationListener.
|
void |
removeLogger(String name)
Remove a LoggerConfig.
|
void |
setAdvertiser(Advertiser advertiser) |
void |
setConfigurationMonitor(ConfigurationMonitor monitor) |
void |
setLoggerAdditive(Logger logger,
boolean additive)
Marks a LoggerConfig as additive.
|
void |
setName(String name)
Set the name of the configuration.
|
protected void |
setup() |
void |
start()
Initialize the configuration.
|
void |
stop()
Tear down the configuration.
|
protected static byte[] |
toByteArray(InputStream is)
Reads an InputStream using buffered reads into a byte array buffer.
|
addFilter, getFilter, hasFilter, isFiltered, removeFilterequalsImpl, getState, hashCodeImpl, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStoppingclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddFilter, getFilter, hasFilter, isFiltered, removeFilterprotected Node rootNode
protected final List<ConfigurationListener> listeners
protected ConfigurationMonitor monitor
protected boolean isShutdownHookEnabled
protected PluginManager pluginManager
protected AbstractConfiguration(ConfigurationSource configurationSource)
public ConfigurationSource getConfigurationSource()
ConfigurationgetConfigurationSource in interface Configurationpublic List<String> getPluginPackages()
ConfigurationgetPluginPackages in interface Configurationpublic Map<String,String> getProperties()
getProperties in interface Configurationpublic void start()
start in interface LifeCyclestart in class AbstractFilterablepublic void stop()
stop in interface LifeCyclestop in class AbstractFilterablepublic boolean isShutdownHookEnabled()
isShutdownHookEnabled in interface Configurationprotected void setup()
protected Level getDefaultStatus()
protected void createAdvertiser(String advertiserString, ConfigurationSource configSource, byte[] buffer, String contentType)
public <T> T getComponent(String name)
getComponent in interface Configurationpublic void addComponent(String name, Object obj)
addComponent in interface Configurationprotected void doConfigure()
public void setName(String name)
name - The name.public String getName()
getName in interface Configurationpublic void addListener(ConfigurationListener listener)
addListener in interface Configurationlistener - The ConfigurationListener to add.public void removeListener(ConfigurationListener listener)
removeListener in interface Configurationlistener - The ConfigurationListener to remove.public Appender getAppender(String name)
getAppender in interface Configurationname - The name of the Appender.public Map<String,Appender> getAppenders()
getAppenders in interface Configurationpublic void addAppender(Appender appender)
addAppender in interface Configurationappender - The Appender to add.public StrSubstitutor getStrSubstitutor()
getStrSubstitutor in interface Configurationpublic StrSubstitutor getConfigurationStrSubstitutor()
public void setConfigurationMonitor(ConfigurationMonitor monitor)
setConfigurationMonitor in interface Configurationpublic ConfigurationMonitor getConfigurationMonitor()
getConfigurationMonitor in interface Configurationpublic void setAdvertiser(Advertiser advertiser)
setAdvertiser in interface Configurationpublic Advertiser getAdvertiser()
getAdvertiser in interface Configurationpublic void addLoggerAppender(Logger logger, Appender appender)
addLoggerAppender in interface Configurationlogger - The Logger the Appender will be associated with.appender - The Appender.public void addLoggerFilter(Logger logger, Filter filter)
addLoggerFilter in interface Configurationlogger - The Logger the Fo;ter will be associated with.filter - The Filter.public void setLoggerAdditive(Logger logger, boolean additive)
setLoggerAdditive in interface Configurationlogger - The Logger the Appender will be associated with.additive - True if the LoggerConfig should be additive, false otherwise.public void removeAppender(String name)
name - 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 Configurationpublic LoggerConfig getLoggerConfig(String name)
getLoggerConfig in interface Configurationname - The Logger name.public LoggerConfig getRootLogger()
public Map<String,LoggerConfig> getLoggers()
getLoggers in interface Configurationpublic LoggerConfig getLogger(String name)
name - The Logger name.public void addLogger(String name, LoggerConfig loggerConfig)
addLogger in interface Configurationname - The name of the Logger.loggerConfig - The LoggerConfig.public void removeLogger(String name)
removeLogger in interface Configurationname - The name of the Logger.public void createConfiguration(Node node, LogEvent event)
createConfiguration in interface Configurationprotected 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.Copyright © 1999-2021 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.