T
- The BuiltConfiguration type.public class DefaultConfigurationBuilder<T extends BuiltConfiguration> extends Object implements ConfigurationBuilder<T>
Constructor and Description |
---|
DefaultConfigurationBuilder() |
DefaultConfigurationBuilder(Class<T> clazz) |
Modifier and Type | Method and Description |
---|---|
ConfigurationBuilder<T> |
add(AppenderComponentBuilder builder)
Adds an AppenderComponent.
|
protected ConfigurationBuilder<T> |
add(Component parent,
ComponentBuilder<?> builder) |
ConfigurationBuilder<T> |
add(CustomLevelComponentBuilder builder)
Adds a CustomLevel component.
|
ConfigurationBuilder<T> |
add(FilterComponentBuilder builder)
Adds a Filter component.
|
ConfigurationBuilder<T> |
add(LoggerComponentBuilder builder)
Adds a Logger component.
|
ConfigurationBuilder<T> |
add(RootLoggerComponentBuilder builder)
Adds the root Logger component.
|
ConfigurationBuilder<T> |
add(ScriptComponentBuilder builder)
Adds a ScriptComponent.
|
ConfigurationBuilder<T> |
add(ScriptFileComponentBuilder builder)
Adds a ScriptFileComponent.
|
ConfigurationBuilder<T> |
addProperty(String key,
String value)
Adds a Property key and value.
|
ConfigurationBuilder<T> |
addRootProperty(String key,
String value)
Add the properties for the root node.
|
T |
build()
Builds the object after all configuration has been set.
|
T |
build(boolean initialize)
Build the configuration and optionally initialize it.
|
static void |
formatXml(Source source,
Result result) |
AppenderComponentBuilder |
newAppender(String name,
String type)
Returns a builder for creating Appenders.
|
AppenderRefComponentBuilder |
newAppenderRef(String ref)
Returns a builder for creating AppenderRefs.
|
LoggerComponentBuilder |
newAsyncLogger(String name)
Returns a builder for creating Async Loggers.
|
LoggerComponentBuilder |
newAsyncLogger(String name,
boolean includeLocation)
Returns a builder for creating Async Loggers.
|
LoggerComponentBuilder |
newAsyncLogger(String name,
Level level)
Returns a builder for creating Async Loggers.
|
LoggerComponentBuilder |
newAsyncLogger(String name,
Level level,
boolean includeLocation)
Returns a builder for creating Async Loggers.
|
LoggerComponentBuilder |
newAsyncLogger(String name,
String level)
Returns a builder for creating Async Loggers.
|
LoggerComponentBuilder |
newAsyncLogger(String name,
String level,
boolean includeLocation)
Returns a builder for creating Async Loggers.
|
RootLoggerComponentBuilder |
newAsyncRootLogger()
Returns a builder for creating the async root Logger.
|
RootLoggerComponentBuilder |
newAsyncRootLogger(boolean includeLocation)
Returns a builder for creating the async root Logger.
|
RootLoggerComponentBuilder |
newAsyncRootLogger(Level level)
Returns a builder for creating the async root Logger.
|
RootLoggerComponentBuilder |
newAsyncRootLogger(Level level,
boolean includeLocation)
Returns a builder for creating the async root Logger.
|
RootLoggerComponentBuilder |
newAsyncRootLogger(String level)
Returns a builder for creating the async root Logger.
|
RootLoggerComponentBuilder |
newAsyncRootLogger(String level,
boolean includeLocation)
Returns a builder for creating the async root Logger.
|
<B extends ComponentBuilder<B>> |
newComponent(String type)
Returns a builder for creating generic components.
|
<B extends ComponentBuilder<B>> |
newComponent(String name,
String type)
Returns a builder for creating generic components.
|
<B extends ComponentBuilder<B>> |
newComponent(String name,
String type,
String value)
Returns a builder for creating generic components.
|
CustomLevelComponentBuilder |
newCustomLevel(String name,
int level)
Returns a builder for creating CustomLevels
|
FilterComponentBuilder |
newFilter(String type,
Filter.Result onMatch,
Filter.Result onMismatch)
Returns a builder for creating Filters.
|
FilterComponentBuilder |
newFilter(String type,
String onMatch,
String onMismatch)
Returns a builder for creating Filters.
|
KeyValuePairComponentBuilder |
newKeyValuePair(String key,
String value)
Returns a builder for creating KeyValuePair:s
|
LayoutComponentBuilder |
newLayout(String type)
Returns a builder for creating Layouts.
|
LoggerComponentBuilder |
newLogger(String name)
Returns a builder for creating Loggers.
|
LoggerComponentBuilder |
newLogger(String name,
boolean includeLocation)
Returns a builder for creating Loggers.
|
LoggerComponentBuilder |
newLogger(String name,
Level level)
Returns a builder for creating Loggers.
|
LoggerComponentBuilder |
newLogger(String name,
Level level,
boolean includeLocation)
Returns a builder for creating Loggers.
|
LoggerComponentBuilder |
newLogger(String name,
String level)
Returns a builder for creating Loggers.
|
LoggerComponentBuilder |
newLogger(String name,
String level,
boolean includeLocation)
Returns a builder for creating Loggers.
|
PropertyComponentBuilder |
newProperty(String name,
String value)
Returns a builder for creating Property:s
|
RootLoggerComponentBuilder |
newRootLogger()
Returns a builder for creating the root Logger.
|
RootLoggerComponentBuilder |
newRootLogger(boolean includeLocation)
Returns a builder for creating the root Logger.
|
RootLoggerComponentBuilder |
newRootLogger(Level level)
Returns a builder for creating the root Logger.
|
RootLoggerComponentBuilder |
newRootLogger(Level level,
boolean includeLocation)
Returns a builder for creating the root Logger.
|
RootLoggerComponentBuilder |
newRootLogger(String level)
Returns a builder for creating the root Logger.
|
RootLoggerComponentBuilder |
newRootLogger(String level,
boolean includeLocation)
Returns a builder for creating the root Logger.
|
ScriptComponentBuilder |
newScript(String name,
String language,
String text)
Returns a builder for creating Async Loggers.
|
ScriptFileComponentBuilder |
newScriptFile(String path)
Returns a builder for creating Async Loggers.
|
ScriptFileComponentBuilder |
newScriptFile(String name,
String path)
Returns a builder for creating Async Loggers.
|
ConfigurationBuilder<T> |
setAdvertiser(String advertiser)
Set the Advertiser Plugin name.
|
ConfigurationBuilder<T> |
setConfigurationName(String name)
Set the name of the configuration.
|
ConfigurationBuilder<T> |
setConfigurationSource(ConfigurationSource configurationSource)
Set the ConfigurationSource.
|
ConfigurationBuilder<T> |
setDestination(String destination)
Specifies the destination for StatusLogger events.
|
void |
setLoggerContext(LoggerContext loggerContext)
Sets the logger context.
|
ConfigurationBuilder<T> |
setMonitorInterval(String intervalSeconds)
Sets the interval at which the configuration file should be checked for changes.
|
ConfigurationBuilder<T> |
setPackages(String packages)
Sets the list of packages to search for plugins.
|
ConfigurationBuilder<T> |
setShutdownHook(String flag)
Sets whether the shutdown hook should be disabled.
|
ConfigurationBuilder<T> |
setShutdownTimeout(long timeout,
TimeUnit timeUnit)
How long appenders and background tasks will get to shutdown when the JVM shuts down.
|
ConfigurationBuilder<T> |
setStatusLevel(Level level)
Sets the level of the StatusLogger.
|
ConfigurationBuilder<T> |
setVerbosity(String verbosity)
Sets whether the logging should include constructing Plugins.
|
String |
toXmlConfiguration()
Constructs an XML configuration from this builder.
|
void |
writeXmlConfiguration(OutputStream output)
Constructs an XML configuration from this builder.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getErrorPrefix, isValid
public static void formatXml(Source source, Result result) throws TransformerConfigurationException, TransformerFactoryConfigurationError, TransformerException
protected ConfigurationBuilder<T> add(Component parent, ComponentBuilder<?> builder)
public ConfigurationBuilder<T> add(AppenderComponentBuilder builder)
ConfigurationBuilder
add
in interface ConfigurationBuilder<T extends BuiltConfiguration>
builder
- The AppenderComponentBuilder with all of its attributes and sub components set.public ConfigurationBuilder<T> add(CustomLevelComponentBuilder builder)
ConfigurationBuilder
add
in interface ConfigurationBuilder<T extends BuiltConfiguration>
builder
- The CustomLevelComponentBuilder with all of its attributes set.public ConfigurationBuilder<T> add(FilterComponentBuilder builder)
ConfigurationBuilder
add
in interface ConfigurationBuilder<T extends BuiltConfiguration>
builder
- the FilterComponentBuilder with all of its attributes and sub components set.public ConfigurationBuilder<T> add(ScriptComponentBuilder builder)
ConfigurationBuilder
add
in interface ConfigurationBuilder<T extends BuiltConfiguration>
builder
- The ScriptComponentBuilder with all of its attributes and sub components set.public ConfigurationBuilder<T> add(ScriptFileComponentBuilder builder)
ConfigurationBuilder
add
in interface ConfigurationBuilder<T extends BuiltConfiguration>
builder
- The ScriptFileComponentBuilder with all of its attributes and sub components set.public ConfigurationBuilder<T> add(LoggerComponentBuilder builder)
ConfigurationBuilder
add
in interface ConfigurationBuilder<T extends BuiltConfiguration>
builder
- The LoggerComponentBuilder with all of its attributes and sub components set.public ConfigurationBuilder<T> add(RootLoggerComponentBuilder builder)
ConfigurationBuilder
add
in interface ConfigurationBuilder<T extends BuiltConfiguration>
builder
- The RootLoggerComponentBuilder with all of its attributes and sub components set.public ConfigurationBuilder<T> addProperty(String key, String value)
ConfigurationBuilder
addProperty
in interface ConfigurationBuilder<T extends BuiltConfiguration>
key
- The property key.value
- The property value.public T build()
Builder
build
in interface Builder<T extends BuiltConfiguration>
public T build(boolean initialize)
ConfigurationBuilder
build
in interface ConfigurationBuilder<T extends BuiltConfiguration>
initialize
- true if the configuration should be initialized, false otherwise. Generally, Configurations
should not be initialized when they are constructed.public void writeXmlConfiguration(OutputStream output) throws IOException
ConfigurationBuilder
writeXmlConfiguration
in interface ConfigurationBuilder<T extends BuiltConfiguration>
output
- OutputStream to write to, will not be closedIOException
public String toXmlConfiguration()
ConfigurationBuilder
toXmlConfiguration
in interface ConfigurationBuilder<T extends BuiltConfiguration>
public ScriptComponentBuilder newScript(String name, String language, String text)
ConfigurationBuilder
newScript
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.language
- The script languagetext
- The script to execute.public ScriptFileComponentBuilder newScriptFile(String path)
ConfigurationBuilder
newScriptFile
in interface ConfigurationBuilder<T extends BuiltConfiguration>
path
- The location of the script file.public ScriptFileComponentBuilder newScriptFile(String name, String path)
ConfigurationBuilder
newScriptFile
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the script file.path
- The location of the script file.public AppenderComponentBuilder newAppender(String name, String type)
ConfigurationBuilder
newAppender
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Appender.type
- The Plugin type of the Appender.public AppenderRefComponentBuilder newAppenderRef(String ref)
ConfigurationBuilder
newAppenderRef
in interface ConfigurationBuilder<T extends BuiltConfiguration>
ref
- The name of the Appender being referenced.public LoggerComponentBuilder newAsyncLogger(String name)
ConfigurationBuilder
newAsyncLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.public LoggerComponentBuilder newAsyncLogger(String name, boolean includeLocation)
ConfigurationBuilder
newAsyncLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.includeLocation
- If true include location information.public LoggerComponentBuilder newAsyncLogger(String name, Level level)
ConfigurationBuilder
newAsyncLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.public LoggerComponentBuilder newAsyncLogger(String name, Level level, boolean includeLocation)
ConfigurationBuilder
newAsyncLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.includeLocation
- If true include location information.public LoggerComponentBuilder newAsyncLogger(String name, String level)
ConfigurationBuilder
newAsyncLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.public LoggerComponentBuilder newAsyncLogger(String name, String level, boolean includeLocation)
ConfigurationBuilder
newAsyncLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.includeLocation
- If true include location information.public RootLoggerComponentBuilder newAsyncRootLogger()
ConfigurationBuilder
newAsyncRootLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
public RootLoggerComponentBuilder newAsyncRootLogger(boolean includeLocation)
ConfigurationBuilder
newAsyncRootLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
includeLocation
- If true include location information.public RootLoggerComponentBuilder newAsyncRootLogger(Level level)
ConfigurationBuilder
newAsyncRootLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
level
- The logging Level to be assigned to the root Logger.public RootLoggerComponentBuilder newAsyncRootLogger(Level level, boolean includeLocation)
ConfigurationBuilder
newAsyncRootLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
level
- The logging Level to be assigned to the root Logger.includeLocation
- If true include location information.public RootLoggerComponentBuilder newAsyncRootLogger(String level)
ConfigurationBuilder
newAsyncRootLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
level
- The logging Level to be assigned to the root Logger.public RootLoggerComponentBuilder newAsyncRootLogger(String level, boolean includeLocation)
ConfigurationBuilder
newAsyncRootLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
level
- The logging Level to be assigned to the root Logger.includeLocation
- If true include location information.public <B extends ComponentBuilder<B>> ComponentBuilder<B> newComponent(String type)
ConfigurationBuilder
newComponent
in interface ConfigurationBuilder<T extends BuiltConfiguration>
B
- ComponentBuilder target typetype
- The Plugin type of the component.public <B extends ComponentBuilder<B>> ComponentBuilder<B> newComponent(String name, String type)
ConfigurationBuilder
newComponent
in interface ConfigurationBuilder<T extends BuiltConfiguration>
B
- ComponentBuilder target typename
- The name of the component (may be null).type
- The Plugin type of the component.public <B extends ComponentBuilder<B>> ComponentBuilder<B> newComponent(String name, String type, String value)
ConfigurationBuilder
newComponent
in interface ConfigurationBuilder<T extends BuiltConfiguration>
B
- ComponentBuilder target typename
- The name of the component (may be null).type
- The Plugin type of the component.value
- The value of the component.public PropertyComponentBuilder newProperty(String name, String value)
ConfigurationBuilder
newProperty
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the property.value
- The value of the component.public KeyValuePairComponentBuilder newKeyValuePair(String key, String value)
ConfigurationBuilder
newKeyValuePair
in interface ConfigurationBuilder<T extends BuiltConfiguration>
key
- The namevalue
- The valuepublic CustomLevelComponentBuilder newCustomLevel(String name, int level)
ConfigurationBuilder
newCustomLevel
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the custom level.level
- The integer value to be assigned to the level.public FilterComponentBuilder newFilter(String type, Filter.Result onMatch, Filter.Result onMismatch)
ConfigurationBuilder
newFilter
in interface ConfigurationBuilder<T extends BuiltConfiguration>
type
- The Plugin type of the Filter.onMatch
- "ACCEPT", "DENY", or "NEUTRAL"onMismatch
- "ACCEPT", "DENY", or "NEUTRAL"public FilterComponentBuilder newFilter(String type, String onMatch, String onMismatch)
ConfigurationBuilder
newFilter
in interface ConfigurationBuilder<T extends BuiltConfiguration>
type
- The Plugin type of the Filter.onMatch
- "ACCEPT", "DENY", or "NEUTRAL"onMismatch
- "ACCEPT", "DENY", or "NEUTRAL"public LayoutComponentBuilder newLayout(String type)
ConfigurationBuilder
newLayout
in interface ConfigurationBuilder<T extends BuiltConfiguration>
type
- The Plugin type of the Layout.public LoggerComponentBuilder newLogger(String name)
ConfigurationBuilder
newLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.public LoggerComponentBuilder newLogger(String name, boolean includeLocation)
ConfigurationBuilder
newLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.includeLocation
- If true include location information.public LoggerComponentBuilder newLogger(String name, Level level)
ConfigurationBuilder
newLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.public LoggerComponentBuilder newLogger(String name, Level level, boolean includeLocation)
ConfigurationBuilder
newLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.includeLocation
- If true include location information.public LoggerComponentBuilder newLogger(String name, String level)
ConfigurationBuilder
newLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.public LoggerComponentBuilder newLogger(String name, String level, boolean includeLocation)
ConfigurationBuilder
newLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.includeLocation
- If true include location information.public RootLoggerComponentBuilder newRootLogger()
ConfigurationBuilder
newRootLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
public RootLoggerComponentBuilder newRootLogger(boolean includeLocation)
ConfigurationBuilder
newRootLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
includeLocation
- If true include location information.public RootLoggerComponentBuilder newRootLogger(Level level)
ConfigurationBuilder
newRootLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
level
- The logging Level to be assigned to the root Logger.public RootLoggerComponentBuilder newRootLogger(Level level, boolean includeLocation)
ConfigurationBuilder
newRootLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
level
- The logging Level to be assigned to the root Logger.includeLocation
- If true include location information.public RootLoggerComponentBuilder newRootLogger(String level)
ConfigurationBuilder
newRootLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
level
- The logging Level to be assigned to the root Logger.public RootLoggerComponentBuilder newRootLogger(String level, boolean includeLocation)
ConfigurationBuilder
newRootLogger
in interface ConfigurationBuilder<T extends BuiltConfiguration>
level
- The logging Level to be assigned to the root Logger.public ConfigurationBuilder<T> setAdvertiser(String advertiser)
ConfigurationBuilder
setAdvertiser
in interface ConfigurationBuilder<T extends BuiltConfiguration>
advertiser
- The Advertiser Plugin name.public ConfigurationBuilder<T> setConfigurationName(String name)
setConfigurationName
in interface ConfigurationBuilder<T extends BuiltConfiguration>
name
- the name of the Configuration
. By default is "Assembled"
.public ConfigurationBuilder<T> setConfigurationSource(ConfigurationSource configurationSource)
setConfigurationSource
in interface ConfigurationBuilder<T extends BuiltConfiguration>
configurationSource
- the ConfigurationSource
public ConfigurationBuilder<T> setMonitorInterval(String intervalSeconds)
ConfigurationBuilder
setMonitorInterval
in interface ConfigurationBuilder<T extends BuiltConfiguration>
intervalSeconds
- The number of seconds that should pass between checks of the configuration file.public ConfigurationBuilder<T> setPackages(String packages)
ConfigurationBuilder
setPackages
in interface ConfigurationBuilder<T extends BuiltConfiguration>
packages
- The comma separated list of packages.public ConfigurationBuilder<T> setShutdownHook(String flag)
ConfigurationBuilder
setShutdownHook
in interface ConfigurationBuilder<T extends BuiltConfiguration>
flag
- "disable" will prevent the shutdown hook from being set.public ConfigurationBuilder<T> setShutdownTimeout(long timeout, TimeUnit timeUnit)
ConfigurationBuilder
ConfigurationBuilder.setShutdownHook(String)
is set to "disable".)setShutdownTimeout
in interface ConfigurationBuilder<T extends BuiltConfiguration>
LoggerContext.stop(long, TimeUnit)
public ConfigurationBuilder<T> setStatusLevel(Level level)
ConfigurationBuilder
setStatusLevel
in interface ConfigurationBuilder<T extends BuiltConfiguration>
level
- The logging level.public ConfigurationBuilder<T> setVerbosity(String verbosity)
ConfigurationBuilder
setVerbosity
in interface ConfigurationBuilder<T extends BuiltConfiguration>
verbosity
- "disable" will hide messages from plugin construction.public ConfigurationBuilder<T> setDestination(String destination)
ConfigurationBuilder
out
(default) for using
standard out
, err
for using standard error
, or a file URI to
which log events will be written. If the provided URI is invalid, then the default destination of standard
out will be used.setDestination
in interface ConfigurationBuilder<T extends BuiltConfiguration>
destination
- where status log messages should be output.public void setLoggerContext(LoggerContext loggerContext)
ConfigurationBuilder
setLoggerContext
in interface ConfigurationBuilder<T extends BuiltConfiguration>
loggerContext
- the logger context.public ConfigurationBuilder<T> addRootProperty(String key, String value)
ConfigurationBuilder
addRootProperty
in interface ConfigurationBuilder<T extends BuiltConfiguration>
key
- The property key.value
- The property value. Copyright © 1999-2023 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.