Interface ConfigurationBuilder<T extends Configuration>
- Type Parameters:
T
- The Configuration type created by this builder.
- All Superinterfaces:
Builder<T>
- All Known Implementing Classes:
DefaultConfigurationBuilder
Interface for building logging configurations.
- Since:
- 2.4
-
Method Summary
Modifier and TypeMethodDescriptionadd
(AppenderComponentBuilder builder) Adds an AppenderComponent.add
(CustomLevelComponentBuilder builder) Adds a CustomLevel component.add
(FilterComponentBuilder builder) Adds a Filter component.add
(LoggerComponentBuilder builder) Adds a Logger component.add
(RootLoggerComponentBuilder builder) Adds the root Logger component.add
(ScriptComponentBuilder builder) Adds a ScriptComponent.add
(ScriptFileComponentBuilder builder) Adds a ScriptFileComponent.addProperty
(String key, String value) Adds a Property key and value.addRootProperty
(String key, String value) Add the properties for the root node.build
(boolean initialize) Build the configuration and optionally initialize it.newAppender
(String name, String pluginName) Returns a builder for creating Appenders.newAppenderRef
(String ref) Returns a builder for creating AppenderRefs.newAsyncLogger
(String name) Returns a builder for creating Async Loggers.newAsyncLogger
(String name, boolean includeLocation) Returns a builder for creating Async Loggers.newAsyncLogger
(String name, String level) Returns a builder for creating Async Loggers.newAsyncLogger
(String name, String level, boolean includeLocation) Returns a builder for creating Async Loggers.newAsyncLogger
(String name, Level level) Returns a builder for creating Async Loggers.newAsyncLogger
(String name, Level level, boolean includeLocation) Returns a builder for creating Async Loggers.Returns a builder for creating the async root Logger.newAsyncRootLogger
(boolean includeLocation) Returns a builder for creating the async root Logger.newAsyncRootLogger
(String level) Returns a builder for creating the async root Logger.newAsyncRootLogger
(String level, boolean includeLocation) Returns a builder for creating the async root Logger.newAsyncRootLogger
(Level level) Returns a builder for creating the async root Logger.newAsyncRootLogger
(Level level, boolean includeLocation) Returns a builder for creating the async root Logger.<B extends ComponentBuilder<B>>
ComponentBuilder<B>newComponent
(String pluginName) Returns a builder for creating generic components.<B extends ComponentBuilder<B>>
ComponentBuilder<B>newComponent
(String name, String pluginName) Returns a builder for creating generic components.<B extends ComponentBuilder<B>>
ComponentBuilder<B>newComponent
(String name, String pluginName, String value) Returns a builder for creating generic components.newCustomLevel
(String name, int level) Returns a builder for creating CustomLevelsReturns a builder for creating Filters.newFilter
(String pluginName, Filter.Result onMatch, Filter.Result onMismatch) Returns a builder for creating Filters.newKeyValuePair
(String key, String value) Returns a builder for creating KeyValuePair:sReturns a builder for creating Layouts.Returns a builder for creating Loggers.Returns a builder for creating Loggers.Returns a builder for creating Loggers.Returns a builder for creating Loggers.Returns a builder for creating Loggers.Returns a builder for creating Loggers.newProperty
(String name, String value) Returns a builder for creating Property:sReturns a builder for creating the root Logger.newRootLogger
(boolean includeLocation) Returns a builder for creating the root Logger.newRootLogger
(String level) Returns a builder for creating the root Logger.newRootLogger
(String level, boolean includeLocation) Returns a builder for creating the root Logger.newRootLogger
(Level level) Returns a builder for creating the root Logger.newRootLogger
(Level level, boolean includeLocation) Returns a builder for creating the root Logger.Returns a builder for creating Async Loggers.newScriptFile
(String path) Returns a builder for creating Async Loggers.newScriptFile
(String name, String path) Returns a builder for creating Async Loggers.setAdvertiser
(String advertiser) Set the Advertiser Plugin name.setConfigurationName
(String name) Sets the name of the configuration.setConfigurationSource
(ConfigurationSource configurationSource) Sets the configuration source, if one exists.setDestination
(String destination) Specifies the destination for StatusLogger events.void
setLoggerContext
(LoggerContext loggerContext) Sets the logger context.setMonitorInterval
(String intervalSeconds) Sets the interval at which the configuration file should be checked for changes.setPackages
(String packages) Sets the list of packages to search for plugins.setShutdownHook
(String flag) Sets whether the shutdown hook should be disabled.setShutdownTimeout
(long timeout, TimeUnit timeUnit) How long appenders and background tasks will get to shutdown when the JVM shuts down.setStatusLevel
(Level level) Sets the level of the StatusLogger.setVerbosity
(String verbosity) Sets whether the logging should include constructing Plugins.Constructs an XML configuration from this builder.void
writeXmlConfiguration
(OutputStream output) Constructs an XML configuration from this builder.Methods inherited from interface org.apache.logging.log4j.core.util.Builder
build, getErrorPrefix, isValid
-
Method Details
-
add
Adds a ScriptComponent.- Parameters:
builder
- The ScriptComponentBuilder with all of its attributes and sub components set.- Returns:
- this builder instance.
-
add
Adds a ScriptFileComponent.- Parameters:
builder
- The ScriptFileComponentBuilder with all of its attributes and sub components set.- Returns:
- this builder instance.
-
add
Adds an AppenderComponent.- Parameters:
builder
- The AppenderComponentBuilder with all of its attributes and sub components set.- Returns:
- this builder instance.
-
add
Adds a CustomLevel component.- Parameters:
builder
- The CustomLevelComponentBuilder with all of its attributes set.- Returns:
- this builder instance.
-
add
Adds a Filter component.- Parameters:
builder
- the FilterComponentBuilder with all of its attributes and sub components set.- Returns:
- this builder instance.
-
add
Adds a Logger component.- Parameters:
builder
- The LoggerComponentBuilder with all of its attributes and sub components set.- Returns:
- this builder instance.
-
add
Adds the root Logger component.- Parameters:
builder
- The RootLoggerComponentBuilder with all of its attributes and sub components set.- Returns:
- this builder instance.
-
addProperty
Adds a Property key and value.- Parameters:
key
- The property key.value
- The property value.- Returns:
- this builder instance.
-
newScript
Returns a builder for creating Async Loggers.- Parameters:
name
- The name of the Logger.language
- The script languagetext
- The script to execute.- Returns:
- A new ScriptComponentBuilder.
-
newScriptFile
Returns a builder for creating Async Loggers.- Parameters:
path
- The location of the script file.- Returns:
- A new ScriptFileComponentBuilder.
-
newScriptFile
Returns a builder for creating Async Loggers.- Parameters:
name
- The name of the script file.path
- The location of the script file.- Returns:
- A new ScriptFileComponentBuilder.
-
newAppender
Returns a builder for creating Appenders.- Parameters:
name
- The name of the Appender.pluginName
- The Plugin type of the Appender.- Returns:
- A new AppenderComponentBuilder.
-
newAppenderRef
Returns a builder for creating AppenderRefs.- Parameters:
ref
- The name of the Appender being referenced.- Returns:
- A new AppenderRefComponentBuilder.
-
newAsyncLogger
Returns a builder for creating Async Loggers.- Parameters:
name
- The name of the Logger.- Returns:
- A new LoggerComponentBuilder.
-
newAsyncLogger
Returns a builder for creating Async Loggers.- Parameters:
name
- The name of the Logger.includeLocation
- If true include location information.- Returns:
- A new LoggerComponentBuilder.
-
newAsyncLogger
Returns a builder for creating Async Loggers.- Parameters:
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.- Returns:
- A new LoggerComponentBuilder.
-
newAsyncLogger
Returns a builder for creating Async Loggers.- Parameters:
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.includeLocation
- If true include location information.- Returns:
- A new LoggerComponentBuilder.
-
newAsyncLogger
Returns a builder for creating Async Loggers.- Parameters:
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.- Returns:
- A new LoggerComponentBuilder.
-
newAsyncLogger
Returns a builder for creating Async Loggers.- Parameters:
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.includeLocation
- If true include location information.- Returns:
- A new LoggerComponentBuilder.
-
newAsyncRootLogger
RootLoggerComponentBuilder newAsyncRootLogger()Returns a builder for creating the async root Logger.- Returns:
- A new RootLoggerComponentBuilder.
-
newAsyncRootLogger
Returns a builder for creating the async root Logger.- Parameters:
includeLocation
- If true include location information.- Returns:
- A new RootLoggerComponentBuilder.
-
newAsyncRootLogger
Returns a builder for creating the async root Logger.- Parameters:
level
- The logging Level to be assigned to the root Logger.- Returns:
- A new RootLoggerComponentBuilder.
-
newAsyncRootLogger
Returns a builder for creating the async root Logger.- Parameters:
level
- The logging Level to be assigned to the root Logger.includeLocation
- If true include location information.- Returns:
- A new RootLoggerComponentBuilder.
-
newAsyncRootLogger
Returns a builder for creating the async root Logger.- Parameters:
level
- The logging Level to be assigned to the root Logger.- Returns:
- A new RootLoggerComponentBuilder.
-
newAsyncRootLogger
Returns a builder for creating the async root Logger.- Parameters:
level
- The logging Level to be assigned to the root Logger.includeLocation
- If true include location information.- Returns:
- A new RootLoggerComponentBuilder.
-
newComponent
Returns a builder for creating generic components.- Type Parameters:
B
- ComponentBuilder target type- Parameters:
pluginName
- The Plugin type of the component.- Returns:
- A new ComponentBuilder.
-
newComponent
Returns a builder for creating generic components.- Type Parameters:
B
- ComponentBuilder target type- Parameters:
name
- The name of the component (may be null).pluginName
- The Plugin type of the component.- Returns:
- A new ComponentBuilder.
-
newComponent
<B extends ComponentBuilder<B>> ComponentBuilder<B> newComponent(String name, String pluginName, String value) Returns a builder for creating generic components.- Type Parameters:
B
- ComponentBuilder target type- Parameters:
name
- The name of the component (may be null).pluginName
- The Plugin type of the component.value
- The value of the component.- Returns:
- A new ComponentBuilder.
-
newProperty
Returns a builder for creating Property:s- Parameters:
name
- The name of the property.value
- The value of the component.- Returns:
- A new PropertyComponentBuilder.
-
newKeyValuePair
Returns a builder for creating KeyValuePair:s- Parameters:
key
- The namevalue
- The value- Returns:
- A new KeyValuePairComponentBuilder.
-
newCustomLevel
Returns a builder for creating CustomLevels- Parameters:
name
- The name of the custom level.level
- The integer value to be assigned to the level.- Returns:
- A new CustomLevelComponentBuilder.
-
newFilter
FilterComponentBuilder newFilter(String pluginName, Filter.Result onMatch, Filter.Result onMismatch) Returns a builder for creating Filters.- Parameters:
pluginName
- The Plugin type of the Filter.onMatch
- "ACCEPT", "DENY", or "NEUTRAL"onMismatch
- "ACCEPT", "DENY", or "NEUTRAL"- Returns:
- A new FilterComponentBuilder.
-
newFilter
Returns a builder for creating Filters.- Parameters:
pluginName
- The Plugin type of the Filter.onMatch
- "ACCEPT", "DENY", or "NEUTRAL"onMismatch
- "ACCEPT", "DENY", or "NEUTRAL"- Returns:
- A new FilterComponentBuilder.
-
newLayout
Returns a builder for creating Layouts.- Parameters:
pluginName
- The Plugin type of the Layout.- Returns:
- A new LayoutComponentBuilder.
-
newLogger
Returns a builder for creating Loggers.- Parameters:
name
- The name of the Logger.- Returns:
- A new LoggerComponentBuilder.
-
newLogger
Returns a builder for creating Loggers.- Parameters:
name
- The name of the Logger.includeLocation
- If true include location information.- Returns:
- A new LoggerComponentBuilder.
-
newLogger
Returns a builder for creating Loggers.- Parameters:
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.- Returns:
- A new LoggerComponentBuilder.
-
newLogger
Returns a builder for creating Loggers.- Parameters:
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.includeLocation
- If true include location information.- Returns:
- A new LoggerComponentBuilder.
-
newLogger
Returns a builder for creating Loggers.- Parameters:
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.- Returns:
- A new LoggerComponentBuilder.
-
newLogger
Returns a builder for creating Loggers.- Parameters:
name
- The name of the Logger.level
- The logging Level to be assigned to the Logger.includeLocation
- If true include location information.- Returns:
- A new LoggerComponentBuilder.
-
newRootLogger
RootLoggerComponentBuilder newRootLogger()Returns a builder for creating the root Logger.- Returns:
- A new RootLoggerComponentBuilder.
-
newRootLogger
Returns a builder for creating the root Logger.- Parameters:
includeLocation
- If true include location information.- Returns:
- A new RootLoggerComponentBuilder.
-
newRootLogger
Returns a builder for creating the root Logger.- Parameters:
level
- The logging Level to be assigned to the root Logger.- Returns:
- A new RootLoggerComponentBuilder.
-
newRootLogger
Returns a builder for creating the root Logger.- Parameters:
level
- The logging Level to be assigned to the root Logger.includeLocation
- If true include location information.- Returns:
- A new RootLoggerComponentBuilder.
-
newRootLogger
Returns a builder for creating the root Logger.- Parameters:
level
- The logging Level to be assigned to the root Logger.- Returns:
- A new RootLoggerComponentBuilder.
-
newRootLogger
Returns a builder for creating the root Logger.- Parameters:
level
- The logging Level to be assigned to the root Logger.- Returns:
- A new RootLoggerComponentBuilder.
-
setAdvertiser
Set the Advertiser Plugin name.- Parameters:
advertiser
- The Advertiser Plugin name.- Returns:
- this builder instance.
-
setConfigurationName
Sets the name of the configuration.- Parameters:
name
- the name of theConfiguration
. By default is"Constructed"
.- Returns:
- this builder instance.
-
setConfigurationSource
Sets the configuration source, if one exists.- Parameters:
configurationSource
- the ConfigurationSource.- Returns:
- this builder instance.
-
setMonitorInterval
Sets the interval at which the configuration file should be checked for changes.- Parameters:
intervalSeconds
- The number of seconds that should pass between checks of the configuration file.- Returns:
- this builder instance.
-
setPackages
Sets the list of packages to search for plugins.- Parameters:
packages
- The comma separated list of packages.- Returns:
- this builder instance.
-
setShutdownHook
Sets whether the shutdown hook should be disabled.- Parameters:
flag
- "disable" will prevent the shutdown hook from being set.- Returns:
- this builder instance.
-
setShutdownTimeout
How long appenders and background tasks will get to shutdown when the JVM shuts down. Default is zero which mean that each appender uses its default timeout, and don't wait for background tasks. Not all appenders will honor this, it is a hint and not an absolute guarantee that the shutdown procedure will not take longer. Setting this too low increase the risk of losing outstanding log events not yet written to the final destination. (Not used ifsetShutdownHook(String)
is set to "disable".)- Returns:
- this builder instance.
- See Also:
-
setStatusLevel
Sets the level of the StatusLogger.- Parameters:
level
- The logging level.- Returns:
- this builder instance.
-
setVerbosity
Sets whether the logging should include constructing Plugins.- Parameters:
verbosity
- "disable" will hide messages from plugin construction.- Returns:
- this builder instance.
-
setDestination
Specifies the destination for StatusLogger events. This can beout
(default) for usingstandard out
,err
for usingstandard 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.- Parameters:
destination
- where status log messages should be output.- Returns:
- this builder instance.
-
setLoggerContext
Sets the logger context.- Parameters:
loggerContext
- the logger context.
-
addRootProperty
Add the properties for the root node.- Parameters:
key
- The property key.value
- The property value.- Returns:
- this builder instance.
-
build
Build the configuration and optionally initialize it.- Parameters:
initialize
- true if the configuration should be initialized, false otherwise. Generally, Configurations should not be initialized when they are constructed.- Returns:
- The constructed Configuration.
-
writeXmlConfiguration
Constructs an XML configuration from this builder.- Parameters:
output
- OutputStream to write to, will not be closed- Throws:
IOException
- Since:
- 2.7
-
toXmlConfiguration
String toXmlConfiguration()Constructs an XML configuration from this builder.- Returns:
- XML configuration
- Since:
- 2.7
-