Top Description Fields Constructors Methods
org.apache.logging.log4j

public Class LogManager

extends Object
Class Inheritance
Imports
java.net.URI, java.util.Map, .SortedMap, .TreeMap, org.apache.logging.log4j.internal.LogManagerStatus, org.apache.logging.log4j.message.MessageFactory, .StringFormatterMessageFactory, org.apache.logging.log4j.simple.SimpleLoggerContextFactory, org.apache.logging.log4j.spi.LoggerContext, .LoggerContextFactory, .Provider, .Terminable, org.apache.logging.log4j.status.StatusLogger, org.apache.logging.log4j.util.LoaderUtil, .PropertiesUtil, .ProviderUtil, .StackLocatorUtil, .Strings

The anchor point for the Log4j logging system. The most common usage of this class is to obtain a named Logger. The method getLogger() is provided as the most convenient way to obtain a named Logger based on the calling class name. This class also provides method for obtaining named Loggers that use String#format(String, Object...) style messages instead of the default type of parameterized messages. These are obtained through the getFormatterLogger(Class) family of methods. Other service provider methods are given through the getContext() and getFactory() family of methods; these methods are not normally useful for typical usage of Log4j.

Field Summary

Modifier and TypeField and Description
private static volatile LoggerContextFactory
public static final String
FACTORY_PROPERTY_NAME

Log4j property to set to the fully qualified class name of a custom implementation of org.apache.logging.log4j.spi.LoggerContextFactory.

private static final String
private static final Logger
public static final String
ROOT_LOGGER_NAME

The name of the root Logger is .

Constructor Summary

AccessConstructor and Description
protected
LogManager()

Prevents instantiation

Method Summary

Modifier and TypeMethod and Description
private static Class<?>
callerClass(final Class<?> clazz)

public static boolean

Returns:

true if the Logger exists, false otherwise.
exists
(final String
The Logger name to search for.
name
)

Detects if a Logger with the specified name exists.

public static LoggerContext

Returns:

The current LoggerContext.
getContext
()

Returns the current LoggerContext.

public static LoggerContext

Returns:

a LoggerContext.
getContext
(final boolean
if false the LoggerContext appropriate for the caller of this method is returned. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be returned and if the caller is a class in the container's classpath then a different LoggerContext may be returned. If true then only a single LoggerContext will be returned.
currentContext
)

Returns a LoggerContext.

public static LoggerContext

Returns:

a LoggerContext.
getContext
(final ClassLoader
The ClassLoader for the context. If null the context will attempt to determine the appropriate ClassLoader.
loader
,
final boolean
if false the LoggerContext appropriate for the caller of this method is returned. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be returned and if the caller is a class in the container's classpath then a different LoggerContext may be returned. If true then only a single LoggerContext will be returned.
currentContext
)

Returns a LoggerContext.

public static LoggerContext

Returns:

a LoggerContext.
getContext
(final ClassLoader
The ClassLoader for the context. If null the context will attempt to determine the appropriate ClassLoader.
loader
,
final boolean
if false the LoggerContext appropriate for the caller of this method is returned. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be returned and if the caller is a class in the container's classpath then a different LoggerContext may be returned. If true then only a single LoggerContext will be returned.
currentContext
,
final Object
An external context (such as a ServletContext) to be associated with the LoggerContext.
externalContext
)

Returns a LoggerContext.

public static LoggerContext

Returns:

a LoggerContext.
getContext
(final ClassLoader
The ClassLoader for the context. If null the context will attempt to determine the appropriate ClassLoader.
loader
,
final boolean
if false the LoggerContext appropriate for the caller of this method is returned. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be returned and if the caller is a class in the container's classpath then a different LoggerContext may be returned. If true then only a single LoggerContext will be returned.
currentContext
,
final URI
The URI for the configuration to use.
configLocation
)

Returns a LoggerContext.

public static LoggerContext

Returns:

a LoggerContext.
getContext
(final ClassLoader
The ClassLoader for the context. If null the context will attempt to determine the appropriate ClassLoader.
loader
,
final boolean
if false the LoggerContext appropriate for the caller of this method is returned. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be returned and if the caller is a class in the container's classpath then a different LoggerContext may be returned. If true then only a single LoggerContext will be returned.
currentContext
,
final Object
An external context (such as a ServletContext) to be associated with the LoggerContext.
externalContext
,
final URI
The URI for the configuration to use.
configLocation
)

Returns a LoggerContext.

public static LoggerContext

Returns:

a LoggerContext.
getContext
(final ClassLoader
The ClassLoader for the context. If null the context will attempt to determine the appropriate ClassLoader.
loader
,
final boolean
if false the LoggerContext appropriate for the caller of this method is returned. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be returned and if the caller is a class in the container's classpath then a different LoggerContext may be returned. If true then only a single LoggerContext will be returned.
currentContext
,
final Object
An external context (such as a ServletContext) to be associated with the LoggerContext.
externalContext
,
final URI
The URI for the configuration to use.
configLocation
,
final String
The LoggerContext name.
name
)

Returns a LoggerContext.

protected static LoggerContext

Returns:

a LoggerContext.
getContext
(final String
The fully qualified class name of the Class that this method is a member of.
fqcn
,
final boolean
if false the LoggerContext appropriate for the caller of this method is returned. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be returned and if the caller is a class in the container's classpath then a different LoggerContext may be returned. If true then only a single LoggerContext will be returned.
currentContext
)

Returns a LoggerContext

protected static LoggerContext

Returns:

a LoggerContext.
getContext
(final String
The fully qualified class name of the Class that this method is a member of.
fqcn
,
final ClassLoader
The ClassLoader for the context. If null the context will attempt to determine the appropriate ClassLoader.
loader
,
final boolean
if false the LoggerContext appropriate for the caller of this method is returned. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be returned and if the caller is a class in the container's classpath then a different LoggerContext may be returned. If true then only a single LoggerContext will be returned.
currentContext
)

Returns a LoggerContext

protected static LoggerContext

Returns:

a LoggerContext.
getContext
(final String
The fully qualified class name of the Class that this method is a member of.
fqcn
,
final ClassLoader
The ClassLoader for the context. If null the context will attempt to determine the appropriate ClassLoader.
loader
,
final boolean
if false the LoggerContext appropriate for the caller of this method is returned. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be returned and if the caller is a class in the container's classpath then a different LoggerContext may be returned. If true then only a single LoggerContext will be returned.
currentContext
,
final URI
The URI for the configuration to use.
configLocation
,
final String
The LoggerContext name.
name
)

Returns a LoggerContext

public static LoggerContextFactory

Returns:

The LoggerContextFactory.
getFactory
()

Returns the current LoggerContextFactory.

public static Logger

Returns:

The Logger for the calling class.
getFormatterLogger
()

Returns a formatter Logger using the fully qualified name of the calling Class as the Logger name.

public static Logger

Returns:

The Logger, created with a StringFormatterMessageFactory
getFormatterLogger
(final Class<?>
The Class whose name should be used as the Logger name.
clazz
)

Returns a formatter Logger using the fully qualified name of the Class as the Logger name.

public static Logger

Returns:

The Logger, created with a StringFormatterMessageFactory
getFormatterLogger
(final Object
The value's whose class name should be used as the Logger name.
value
)

Returns a formatter Logger using the fully qualified name of the value's Class as the Logger name.

public static Logger

Returns:

The Logger, created with a StringFormatterMessageFactory
getFormatterLogger
(final String
The logger name. If null it will default to the name of the calling class.
name
)

Returns a formatter Logger with the specified name.

public static Logger

Returns:

The Logger for the calling class.
getLogger
()

Returns a Logger with the name of the calling class.

public static Logger

Returns:

The Logger.
getLogger
(final Class<?>
The Class whose name should be used as the Logger name. If null it will default to the calling class.
clazz
)

Returns a Logger using the fully qualified name of the Class as the Logger name.

public static Logger

Returns:

The Logger.
getLogger
(final Class<?>
The Class whose name should be used as the Logger name. If null it will default to the calling class.
clazz
,
final MessageFactory
The message factory is used only when creating a logger, subsequent use does not change the logger but will log a warning if mismatched.
messageFactory
)

Returns a Logger using the fully qualified name of the Class as the Logger name.

public static Logger

Returns:

The Logger for the calling class.
getLogger
(final MessageFactory
The message factory is used only when creating a logger, subsequent use does not change the logger but will log a warning if mismatched.
messageFactory
)

Returns a Logger with the name of the calling class.

public static Logger

Returns:

The Logger.
getLogger
(final Object
The value whose class name should be used as the Logger name. If null the name of the calling class will be used as the logger name.
value
)

Returns a Logger using the fully qualified class name of the value as the Logger name.

public static Logger

Returns:

The Logger.
getLogger
(final Object
The value whose class name should be used as the Logger name. If null the name of the calling class will be used as the logger name.
value
,
final MessageFactory
The message factory is used only when creating a logger, subsequent use does not change the logger but will log a warning if mismatched.
messageFactory
)

Returns a Logger using the fully qualified class name of the value as the Logger name.

public static Logger

Returns:

The Logger.
getLogger
(final String
The logger name. If null the name of the calling class will be used.
name
)

Returns a Logger with the specified name.

public static Logger

Returns:

The Logger.
getLogger
(final String
The logger name. If null the name of the calling class will be used.
name
,
final MessageFactory
The message factory is used only when creating a logger, subsequent use does not change the logger but will log a warning if mismatched.
messageFactory
)

Returns a Logger with the specified name.

protected static Logger

Returns:

The Logger.
getLogger
(final String
The fully qualified class name of the class that this method is a member of.
fqcn
,
final String
The logger name.
name
)

Returns a Logger with the specified name.

public static Logger

Returns:

the root logger, named ROOT_LOGGER_NAME.
getRootLogger
()

Returns the root logger.

public static void
setFactory(final LoggerContextFactory
the LoggerContextFactory to use.
factory
)

Sets the current LoggerContextFactory to use.

public static void
shutdown()

Shutdown using the LoggerContext appropriate for the caller of this method.

public static void
shutdown(final boolean
if true a default LoggerContext (may not be the LoggerContext used to create a Logger for the calling class) will be used. If false the LoggerContext appropriate for the caller of this method is used. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be used and if the caller is a class in the container's classpath then a different LoggerContext may be used.
currentContext
)

Shutdown the logging system if the logging system supports it.

public static void
shutdown(final boolean
if true a default LoggerContext (may not be the LoggerContext used to create a Logger for the calling class) will be used. If false the LoggerContext appropriate for the caller of this method is used. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be used and if the caller is a class in the container's classpath then a different LoggerContext may be used.
currentContext
,
final boolean
if true all LoggerContexts that can be located will be shutdown.
allContexts
)

Shutdown the logging system if the logging system supports it.

public static void
shutdown(final LoggerContext
the LoggerContext.
context
)

Shutdown the logging system if the logging system supports it.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

factoryback to summary
private static volatile LoggerContextFactory factory
FACTORY_PROPERTY_NAMEback to summary
public static final String FACTORY_PROPERTY_NAME

Log4j property to set to the fully qualified class name of a custom implementation of org.apache.logging.log4j.spi.LoggerContextFactory.

FQCNback to summary
private static final String FQCN
LOGGERback to summary
private static final Logger LOGGER
ROOT_LOGGER_NAMEback to summary
public static final String ROOT_LOGGER_NAME

The name of the root Logger is .

Constructor Detail

LogManagerback to summary
protected LogManager()

Prevents instantiation

Method Detail

callerClassback to summary
private static Class<?> callerClass(final Class<?> clazz)
existsback to summary
public static boolean exists(final String name)

Detects if a Logger with the specified name exists. This is a convenience method for porting from version 1.

Parameters
name:String

The Logger name to search for.

Returns:boolean

true if the Logger exists, false otherwise.

See Also
LoggerContext#hasLogger(String)
getContextback to summary
public static LoggerContext getContext()

Returns the current LoggerContext.

WARNING - The LoggerContext returned by this method may not be the LoggerContext used to create a Logger for the calling class.

Returns:LoggerContext

The current LoggerContext.

getContextback to summary
public static LoggerContext getContext(final boolean currentContext)

Returns a LoggerContext.

Parameters
currentContext:boolean

if false the LoggerContext appropriate for the caller of this method is returned. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be returned and if the caller is a class in the container's classpath then a different LoggerContext may be returned. If true then only a single LoggerContext will be returned.

Returns:LoggerContext

a LoggerContext.

getContextback to summary
public static LoggerContext getContext(final ClassLoader loader, final boolean currentContext)

Returns a LoggerContext.

Parameters
loader:ClassLoader

The ClassLoader for the context. If null the context will attempt to determine the appropriate ClassLoader.

currentContext:boolean

if false the LoggerContext appropriate for the caller of this method is returned. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be returned and if the caller is a class in the container's classpath then a different LoggerContext may be returned. If true then only a single LoggerContext will be returned.

Returns:LoggerContext

a LoggerContext.

getContextback to summary
public static LoggerContext getContext(final ClassLoader loader, final boolean currentContext, final Object externalContext)

Returns a LoggerContext.

Parameters
loader:ClassLoader

The ClassLoader for the context. If null the context will attempt to determine the appropriate ClassLoader.

currentContext:boolean

if false the LoggerContext appropriate for the caller of this method is returned. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be returned and if the caller is a class in the container's classpath then a different LoggerContext may be returned. If true then only a single LoggerContext will be returned.

externalContext:Object

An external context (such as a ServletContext) to be associated with the LoggerContext.

Returns:LoggerContext

a LoggerContext.

getContextback to summary
public static LoggerContext getContext(final ClassLoader loader, final boolean currentContext, final URI configLocation)

Returns a LoggerContext.

Parameters
loader:ClassLoader

The ClassLoader for the context. If null the context will attempt to determine the appropriate ClassLoader.

currentContext:boolean

if false the LoggerContext appropriate for the caller of this method is returned. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be returned and if the caller is a class in the container's classpath then a different LoggerContext may be returned. If true then only a single LoggerContext will be returned.

configLocation:URI

The URI for the configuration to use.

Returns:LoggerContext

a LoggerContext.

getContextback to summary
public static LoggerContext getContext(final ClassLoader loader, final boolean currentContext, final Object externalContext, final URI configLocation)

Returns a LoggerContext.

Parameters
loader:ClassLoader

The ClassLoader for the context. If null the context will attempt to determine the appropriate ClassLoader.

currentContext:boolean

if false the LoggerContext appropriate for the caller of this method is returned. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be returned and if the caller is a class in the container's classpath then a different LoggerContext may be returned. If true then only a single LoggerContext will be returned.

externalContext:Object

An external context (such as a ServletContext) to be associated with the LoggerContext.

configLocation:URI

The URI for the configuration to use.

Returns:LoggerContext

a LoggerContext.

getContextback to summary
public static LoggerContext getContext(final ClassLoader loader, final boolean currentContext, final Object externalContext, final URI configLocation, final String name)

Returns a LoggerContext.

Parameters
loader:ClassLoader

The ClassLoader for the context. If null the context will attempt to determine the appropriate ClassLoader.

currentContext:boolean

if false the LoggerContext appropriate for the caller of this method is returned. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be returned and if the caller is a class in the container's classpath then a different LoggerContext may be returned. If true then only a single LoggerContext will be returned.

externalContext:Object

An external context (such as a ServletContext) to be associated with the LoggerContext.

configLocation:URI

The URI for the configuration to use.

name:String

The LoggerContext name.

Returns:LoggerContext

a LoggerContext.

getContextback to summary
protected static LoggerContext getContext(final String fqcn, final boolean currentContext)

Returns a LoggerContext

Parameters
fqcn:String

The fully qualified class name of the Class that this method is a member of.

currentContext:boolean

if false the LoggerContext appropriate for the caller of this method is returned. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be returned and if the caller is a class in the container's classpath then a different LoggerContext may be returned. If true then only a single LoggerContext will be returned.

Returns:LoggerContext

a LoggerContext.

getContextback to summary
protected static LoggerContext getContext(final String fqcn, final ClassLoader loader, final boolean currentContext)

Returns a LoggerContext

Parameters
fqcn:String

The fully qualified class name of the Class that this method is a member of.

loader:ClassLoader

The ClassLoader for the context. If null the context will attempt to determine the appropriate ClassLoader.

currentContext:boolean

if false the LoggerContext appropriate for the caller of this method is returned. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be returned and if the caller is a class in the container's classpath then a different LoggerContext may be returned. If true then only a single LoggerContext will be returned.

Returns:LoggerContext

a LoggerContext.

getContextback to summary
protected static LoggerContext getContext(final String fqcn, final ClassLoader loader, final boolean currentContext, final URI configLocation, final String name)

Returns a LoggerContext

Parameters
fqcn:String

The fully qualified class name of the Class that this method is a member of.

loader:ClassLoader

The ClassLoader for the context. If null the context will attempt to determine the appropriate ClassLoader.

currentContext:boolean

if false the LoggerContext appropriate for the caller of this method is returned. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be returned and if the caller is a class in the container's classpath then a different LoggerContext may be returned. If true then only a single LoggerContext will be returned.

configLocation:URI

The URI for the configuration to use.

name:String

The LoggerContext name.

Returns:LoggerContext

a LoggerContext.

getFactoryback to summary
public static LoggerContextFactory getFactory()

Returns the current LoggerContextFactory.

Returns:LoggerContextFactory

The LoggerContextFactory.

getFormatterLoggerback to summary
public static Logger getFormatterLogger()

Returns a formatter Logger using the fully qualified name of the calling Class as the Logger name.

This logger lets you use a java.util.Formatter string in the message to format parameters.

Returns:Logger

The Logger for the calling class.

Exceptions
UnsupportedOperationException:
if the calling class cannot be determined.
Since
2.4
getFormatterLoggerback to summary
public static Logger getFormatterLogger(final Class<?> clazz)

Returns a formatter Logger using the fully qualified name of the Class as the Logger name.

This logger let you use a java.util.Formatter string in the message to format parameters.

Short-hand for getLogger(clazz, StringFormatterMessageFactory.INSTANCE)

Parameters
clazz:Class<?>

The Class whose name should be used as the Logger name.

Returns:Logger

The Logger, created with a StringFormatterMessageFactory

Exceptions
UnsupportedOperationException:
if clazz is null and the calling class cannot be determined.
See Also
Logger#fatal(Marker, String, Object...), Logger#fatal(String, Object...), Logger#error(Marker, String, Object...), Logger#error(String, Object...), Logger#warn(Marker, String, Object...), Logger#warn(String, Object...), Logger#info(Marker, String, Object...), Logger#info(String, Object...), Logger#debug(Marker, String, Object...), Logger#debug(String, Object...), Logger#trace(Marker, String, Object...), Logger#trace(String, Object...), StringFormatterMessageFactory
getFormatterLoggerback to summary
public static Logger getFormatterLogger(final Object value)

Returns a formatter Logger using the fully qualified name of the value's Class as the Logger name.

This logger let you use a java.util.Formatter string in the message to format parameters.

Short-hand for getLogger(value, StringFormatterMessageFactory.INSTANCE)

Parameters
value:Object

The value's whose class name should be used as the Logger name.

Returns:Logger

The Logger, created with a StringFormatterMessageFactory

Exceptions
UnsupportedOperationException:
if value is null and the calling class cannot be determined.
See Also
Logger#fatal(Marker, String, Object...), Logger#fatal(String, Object...), Logger#error(Marker, String, Object...), Logger#error(String, Object...), Logger#warn(Marker, String, Object...), Logger#warn(String, Object...), Logger#info(Marker, String, Object...), Logger#info(String, Object...), Logger#debug(Marker, String, Object...), Logger#debug(String, Object...), Logger#trace(Marker, String, Object...), Logger#trace(String, Object...), StringFormatterMessageFactory
getFormatterLoggerback to summary
public static Logger getFormatterLogger(final String name)

Returns a formatter Logger with the specified name.

This logger let you use a java.util.Formatter string in the message to format parameters.

Short-hand for getLogger(name, StringFormatterMessageFactory.INSTANCE)

Parameters
name:String

The logger name. If null it will default to the name of the calling class.

Returns:Logger

The Logger, created with a StringFormatterMessageFactory

Exceptions
UnsupportedOperationException:
if name is null and the calling class cannot be determined.
See Also
Logger#fatal(Marker, String, Object...), Logger#fatal(String, Object...), Logger#error(Marker, String, Object...), Logger#error(String, Object...), Logger#warn(Marker, String, Object...), Logger#warn(String, Object...), Logger#info(Marker, String, Object...), Logger#info(String, Object...), Logger#debug(Marker, String, Object...), Logger#debug(String, Object...), Logger#trace(Marker, String, Object...), Logger#trace(String, Object...), StringFormatterMessageFactory
getLoggerback to summary
public static Logger getLogger()

Returns a Logger with the name of the calling class.

Returns:Logger

The Logger for the calling class.

Exceptions
UnsupportedOperationException:
if the calling class cannot be determined.
getLoggerback to summary
public static Logger getLogger(final Class<?> clazz)

Returns a Logger using the fully qualified name of the Class as the Logger name.

Parameters
clazz:Class<?>

The Class whose name should be used as the Logger name. If null it will default to the calling class.

Returns:Logger

The Logger.

Exceptions
UnsupportedOperationException:
if clazz is null and the calling class cannot be determined.
getLoggerback to summary
public static Logger getLogger(final Class<?> clazz, final MessageFactory messageFactory)

Returns a Logger using the fully qualified name of the Class as the Logger name.

Parameters
clazz:Class<?>

The Class whose name should be used as the Logger name. If null it will default to the calling class.

messageFactory:MessageFactory

The message factory is used only when creating a logger, subsequent use does not change the logger but will log a warning if mismatched.

Returns:Logger

The Logger.

Exceptions
UnsupportedOperationException:
if clazz is null and the calling class cannot be determined.
getLoggerback to summary
public static Logger getLogger(final MessageFactory messageFactory)

Returns a Logger with the name of the calling class.

Parameters
messageFactory:MessageFactory

The message factory is used only when creating a logger, subsequent use does not change the logger but will log a warning if mismatched.

Returns:Logger

The Logger for the calling class.

Exceptions
UnsupportedOperationException:
if the calling class cannot be determined.
getLoggerback to summary
public static Logger getLogger(final Object value)

Returns a Logger using the fully qualified class name of the value as the Logger name.

Parameters
value:Object

The value whose class name should be used as the Logger name. If null the name of the calling class will be used as the logger name.

Returns:Logger

The Logger.

Exceptions
UnsupportedOperationException:
if value is null and the calling class cannot be determined.
getLoggerback to summary
public static Logger getLogger(final Object value, final MessageFactory messageFactory)

Returns a Logger using the fully qualified class name of the value as the Logger name.

Parameters
value:Object

The value whose class name should be used as the Logger name. If null the name of the calling class will be used as the logger name.

messageFactory:MessageFactory

The message factory is used only when creating a logger, subsequent use does not change the logger but will log a warning if mismatched.

Returns:Logger

The Logger.

Exceptions
UnsupportedOperationException:
if value is null and the calling class cannot be determined.
getLoggerback to summary
public static Logger getLogger(final String name)

Returns a Logger with the specified name.

Parameters
name:String

The logger name. If null the name of the calling class will be used.

Returns:Logger

The Logger.

Exceptions
UnsupportedOperationException:
if name is null and the calling class cannot be determined.
getLoggerback to summary
public static Logger getLogger(final String name, final MessageFactory messageFactory)

Returns a Logger with the specified name.

Parameters
name:String

The logger name. If null the name of the calling class will be used.

messageFactory:MessageFactory

The message factory is used only when creating a logger, subsequent use does not change the logger but will log a warning if mismatched.

Returns:Logger

The Logger.

Exceptions
UnsupportedOperationException:
if name is null and the calling class cannot be determined.
getLoggerback to summary
protected static Logger getLogger(final String fqcn, final String name)

Returns a Logger with the specified name.

Parameters
fqcn:String

The fully qualified class name of the class that this method is a member of.

name:String

The logger name.

Returns:Logger

The Logger.

getRootLoggerback to summary
public static Logger getRootLogger()

Returns the root logger.

Returns:Logger

the root logger, named ROOT_LOGGER_NAME.

setFactoryback to summary
public static void setFactory(final LoggerContextFactory factory)

Sets the current LoggerContextFactory to use. Normally, the appropriate LoggerContextFactory is created at startup, but in certain environments, a LoggerContextFactory implementation may not be available at this point. Thus, an alternative LoggerContextFactory can be set at runtime.

Note that any Logger or LoggerContext objects already created will still be valid, but they will no longer be accessible through LogManager. Thus, it is a bad idea to use this method without a good reason! Generally, this method should be used only during startup before any code starts caching Logger objects.

Parameters
factory:LoggerContextFactory

the LoggerContextFactory to use.

shutdownback to summary
public static void shutdown()

Shutdown using the LoggerContext appropriate for the caller of this method. This is equivalent to calling LogManager.shutdown(false). This call is synchronous and will block until shut down is complete. This may include flushing pending log events over network connections.

Since
2.6
shutdownback to summary
public static void shutdown(final boolean currentContext)

Shutdown the logging system if the logging system supports it. This is equivalent to calling LogManager.shutdown(LogManager.getContext(currentContext)). This call is synchronous and will block until shut down is complete. This may include flushing pending log events over network connections.

Parameters
currentContext:boolean

if true a default LoggerContext (may not be the LoggerContext used to create a Logger for the calling class) will be used. If false the LoggerContext appropriate for the caller of this method is used. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be used and if the caller is a class in the container's classpath then a different LoggerContext may be used.

Since
2.6
shutdownback to summary
public static void shutdown(final boolean currentContext, final boolean allContexts)

Shutdown the logging system if the logging system supports it. This is equivalent to calling LogManager.shutdown(LogManager.getContext(currentContext)). This call is synchronous and will block until shut down is complete. This may include flushing pending log events over network connections.

Parameters
currentContext:boolean

if true a default LoggerContext (may not be the LoggerContext used to create a Logger for the calling class) will be used. If false the LoggerContext appropriate for the caller of this method is used. For example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be used and if the caller is a class in the container's classpath then a different LoggerContext may be used.

allContexts:boolean

if true all LoggerContexts that can be located will be shutdown.

Since
2.13.0
shutdownback to summary
public static void shutdown(final LoggerContext context)

Shutdown the logging system if the logging system supports it. This call is synchronous and will block until shut down is complete. This may include flushing pending log events over network connections.

Parameters
context:LoggerContext

the LoggerContext.

Since
2.6