public final class Configurator
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
FQCN |
private static Logger |
LOGGER |
Modifier | Constructor and Description |
---|---|
private |
Configurator() |
Modifier and Type | Method and Description |
---|---|
private static Log4jContextFactory |
getFactory() |
static LoggerContext |
initialize(java.lang.ClassLoader loader,
Configuration configuration)
Initializes the Logging Context.
|
static LoggerContext |
initialize(java.lang.ClassLoader loader,
Configuration configuration,
java.lang.Object externalContext)
Initializes the Logging Context.
|
static LoggerContext |
initialize(java.lang.ClassLoader loader,
ConfigurationSource source)
Initializes the Logging Context.
|
static LoggerContext |
initialize(java.lang.ClassLoader loader,
ConfigurationSource source,
java.lang.Object externalContext)
Initializes the Logging Context.
|
static LoggerContext |
initialize(Configuration configuration)
Initializes the Logging Context.
|
static LoggerContext |
initialize(java.lang.String name,
java.lang.ClassLoader loader,
java.util.List<java.net.URI> configLocations,
java.lang.Object externalContext) |
static LoggerContext |
initialize(java.lang.String name,
java.lang.ClassLoader loader,
java.lang.String configLocation)
Initializes the Logging Context.
|
static LoggerContext |
initialize(java.lang.String name,
java.lang.ClassLoader loader,
java.lang.String configLocation,
java.lang.Object externalContext)
Initializes the Logging Context.
|
static LoggerContext |
initialize(java.lang.String name,
java.lang.ClassLoader loader,
java.net.URI configLocation)
Initializes the Logging Context.
|
static LoggerContext |
initialize(java.lang.String name,
java.lang.ClassLoader loader,
java.net.URI configLocation,
java.lang.Object externalContext)
Initializes the Logging Context.
|
static LoggerContext |
initialize(java.lang.String name,
java.lang.String configLocation)
Initializes the Logging Context.
|
static void |
setAllLevels(java.lang.String parentLogger,
Level level)
Sets the levels of
parentLogger and all 'child' loggers to the given level . |
private static boolean |
setLevel(LoggerConfig loggerConfig,
Level level) |
static void |
setLevel(java.util.Map<java.lang.String,Level> levelMap)
Sets logger levels.
|
static void |
setLevel(java.lang.String loggerName,
Level level)
Sets a logger's level.
|
private static boolean |
setLevel(java.lang.String loggerName,
Level level,
Configuration config) |
static void |
setRootLevel(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,
java.util.concurrent.TimeUnit timeUnit)
Shuts down the given logger context.
|
private static final java.lang.String FQCN
private static final Logger LOGGER
private static Log4jContextFactory getFactory()
public static LoggerContext initialize(java.lang.ClassLoader loader, ConfigurationSource source)
loader
- The ClassLoader for the Context (or null).source
- The InputSource for the configuration.public static LoggerContext initialize(java.lang.ClassLoader loader, ConfigurationSource source, java.lang.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(java.lang.String name, java.lang.ClassLoader loader, java.lang.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(java.lang.String name, java.lang.ClassLoader loader, java.lang.String configLocation, java.lang.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(java.lang.String name, java.lang.ClassLoader loader, java.net.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(java.lang.String name, java.lang.ClassLoader loader, java.net.URI configLocation, java.lang.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(java.lang.String name, java.lang.ClassLoader loader, java.util.List<java.net.URI> configLocations, java.lang.Object externalContext)
public static LoggerContext initialize(java.lang.String name, java.lang.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(java.lang.ClassLoader loader, Configuration configuration)
loader
- The ClassLoader.configuration
- The Configuration.public static LoggerContext initialize(java.lang.ClassLoader loader, Configuration configuration, java.lang.Object externalContext)
loader
- The ClassLoader.configuration
- The Configuration.externalContext
- - The external context to be attached to the LoggerContext.public static void setAllLevels(java.lang.String parentLogger, Level level)
parentLogger
and all 'child' loggers to the given level
.parentLogger
- the parent loggerlevel
- the new levelprivate static boolean setLevel(LoggerConfig loggerConfig, Level level)
public static void setLevel(java.util.Map<java.lang.String,Level> levelMap)
levelMap
- a levelMap where keys are level names and values are new
Levels.public static void setLevel(java.lang.String loggerName, Level level)
loggerName
- the logger namelevel
- the new levelprivate static boolean setLevel(java.lang.String loggerName, Level level, Configuration config)
public static void setRootLevel(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, java.util.concurrent.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)