public final class Configurator extends Object
Modifier and Type | Method and Description |
---|---|
static LoggerContext |
initialize(ClassLoader loader,
Configuration configuration)
Initializes the Logging Context.
|
static LoggerContext |
initialize(ClassLoader loader,
Configuration configuration,
Object externalContext)
Initializes the Logging Context.
|
static LoggerContext |
initialize(ClassLoader loader,
ConfigurationSource source)
Initializes the Logging Context.
|
static LoggerContext |
initialize(ClassLoader loader,
ConfigurationSource source,
Object externalContext)
Initializes the Logging Context.
|
static LoggerContext |
initialize(Configuration configuration)
Initializes the Logging Context.
|
static LoggerContext |
initialize(String name,
ClassLoader loader,
List<URI> configLocations,
Object externalContext) |
static LoggerContext |
initialize(String name,
ClassLoader loader,
String configLocation)
Initializes the Logging Context.
|
static LoggerContext |
initialize(String name,
ClassLoader loader,
String configLocation,
Object externalContext)
Initializes the Logging Context.
|
static LoggerContext |
initialize(String name,
ClassLoader loader,
URI configLocation)
Initializes the Logging Context.
|
static LoggerContext |
initialize(String name,
ClassLoader loader,
URI configLocation,
Map.Entry<String,Object> entry)
Initializes the Logging Context.
|
static LoggerContext |
initialize(String name,
ClassLoader loader,
URI configLocation,
Object externalContext)
Initializes the Logging Context.
|
static LoggerContext |
initialize(String name,
String configLocation)
Initializes the Logging Context.
|
static void |
reconfigure()
Reload the existing reconfiguration.
|
static void |
reconfigure(Configuration configuration)
Reconfigure using an already constructed Configuration.
|
static void |
reconfigure(URI uri)
Reconfigure with a potentially new configuration.
|
static void |
setAllLevels(String parentLogger,
org.apache.logging.log4j.Level level)
Sets the levels of
parentLogger and all 'child' loggers to the given level . |
static void |
setLevel(Map<String,org.apache.logging.log4j.Level> levelMap)
Sets logger levels.
|
static void |
setLevel(String loggerName,
org.apache.logging.log4j.Level level)
Sets a logger's level.
|
static void |
setRootLevel(org.apache.logging.log4j.Level level)
Sets the root logger's level.
|
static void |
shutdown(LoggerContext ctx)
Shuts down the given logger context.
|
static boolean |
shutdown(LoggerContext ctx,
long timeout,
TimeUnit timeUnit)
Shuts down the given logger context.
|
public static LoggerContext initialize(ClassLoader loader, ConfigurationSource source)
loader
- The ClassLoader for the Context (or null).source
- The InputSource for the configuration.public static LoggerContext initialize(ClassLoader loader, ConfigurationSource source, Object externalContext)
loader
- The ClassLoader for the Context (or null).source
- The InputSource for the configuration.externalContext
- The external context to be attached to the LoggerContext.public static LoggerContext initialize(String name, ClassLoader loader, String configLocation)
name
- The Context name.loader
- The ClassLoader for the Context (or null).configLocation
- The configuration for the logging context.public static LoggerContext initialize(String name, ClassLoader loader, String configLocation, Object externalContext)
name
- The Context name.loader
- The ClassLoader for the Context (or null).configLocation
- The configuration for the logging context (or null, or blank).externalContext
- The external context to be attached to the LoggerContextpublic static LoggerContext initialize(String name, ClassLoader loader, URI configLocation)
name
- The Context name.loader
- The ClassLoader for the Context (or null).configLocation
- The configuration for the logging context.public static LoggerContext initialize(String name, ClassLoader loader, URI configLocation, Object externalContext)
name
- The Context name.loader
- The ClassLoader for the Context (or null).configLocation
- The configuration for the logging context (or null).externalContext
- The external context to be attached to the LoggerContextpublic static LoggerContext initialize(String name, ClassLoader loader, URI configLocation, Map.Entry<String,Object> entry)
name
- The Context name.loader
- The ClassLoader for the Context (or null).configLocation
- The configuration for the logging context (or null).entry
- The external context entry to be attached to the LoggerContextpublic static LoggerContext initialize(String name, ClassLoader loader, List<URI> configLocations, Object externalContext)
public static LoggerContext initialize(String name, String configLocation)
name
- The Context name.configLocation
- The configuration for the logging context.public static LoggerContext initialize(Configuration configuration)
configuration
- The Configuration.public static LoggerContext initialize(ClassLoader loader, Configuration configuration)
loader
- The ClassLoader.configuration
- The Configuration.public static LoggerContext initialize(ClassLoader loader, Configuration configuration, Object externalContext)
loader
- The ClassLoader.configuration
- The Configuration.externalContext
- - The external context to be attached to the LoggerContext.public static void reconfigure(Configuration configuration)
configuration
- The configuration.public static void reconfigure()
public static void reconfigure(URI uri)
uri
- The location of the configuration.public static void setAllLevels(String parentLogger, org.apache.logging.log4j.Level level)
parentLogger
and all 'child' loggers to the given level
.parentLogger
- the parent loggerlevel
- the new levelpublic static void setLevel(Map<String,org.apache.logging.log4j.Level> levelMap)
levelMap
- a levelMap where keys are level names and values are new
Levels.public static void setLevel(String loggerName, org.apache.logging.log4j.Level level)
loggerName
- the logger namelevel
- the new levelpublic static void setRootLevel(org.apache.logging.log4j.Level level)
level
- the new levelpublic static void shutdown(LoggerContext ctx)
Log4j starts threads to perform certain actions like file rollovers; calling this method will not wait until the rollover thread is done. When this method returns, these tasks' status are undefined, the tasks may be done or not.
ctx
- the logger context to shut down, may be null.public static boolean shutdown(LoggerContext ctx, long timeout, TimeUnit timeUnit)
Log4j can start threads to perform certain actions like file rollovers; calling this method with a positive timeout will block until the rollover thread is done.
ctx
- the logger context to shut down, may be null.timeout
- the maximum time to waittimeUnit
- the time unit of the timeout argumenttrue
if the logger context terminated and false
if the timeout elapsed before
termination.LoggerContext.stop(long, TimeUnit)
Copyright © 1999-2021 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.