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

public Class LogManager

extends LogManager
Class Inheritance
Imports
java.util.Collections, .Enumeration, .HashSet, .Set, java.util.logging.Logger, org.apache.logging.log4j.LoggingException, org.apache.logging.log4j.status.StatusLogger, org.apache.logging.log4j.util.LoaderUtil, .PropertiesUtil

Log4j implementation of java.util.logging.LogManager. Note that the system property java.util.logging.manager must be set to org.apache.logging.log4j.jul.LogManager in order to use this adaptor. This LogManager requires the log4j-api library to be available. If log4j-core is also available, then more features of java.util.logging.Logger are supported.

To override the default AbstractLoggerAdapter that is used, specify the Log4j property log4j.jul.LoggerAdapter and set it to the fully qualified class name of a custom implementation. All implementations must have a default constructor.

Since
2.1

Field Summary

Modifier and TypeField and Description
private static final Logger
private final AbstractLoggerAdapter
private final ThreadLocal<Set<String>>
Inherited from java.util.logging.LogManager:
LOGGING_MXBEAN_NAME

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
addLogger(final Logger
the new logger.
logger
)

Overrides java.util.logging.LogManager.addLogger.

Add a named logger.

public Logger
getLogger(final String
name of the logger
name
)

Overrides java.util.logging.LogManager.getLogger.

Method to find a named logger.

public Enumeration<String>
getLoggerNames()

Overrides java.util.logging.LogManager.getLoggerNames.

Get an enumeration of known logger names.

Inherited from java.util.logging.LogManager:
addConfigurationListenercheckAccessgetLoggingMXBeangetLogManagergetPropertyreadConfigurationreadConfigurationremoveConfigurationListenerresetupdateConfigurationupdateConfiguration

Field Detail

LOGGERback to summary
private static final Logger LOGGER
loggerAdapterback to summary
private final AbstractLoggerAdapter loggerAdapter
recursiveback to summary
private final ThreadLocal<Set<String>> recursive

Constructor Detail

LogManagerback to summary
public LogManager()

Method Detail

addLoggerback to summary
public boolean addLogger(final Logger logger)

Overrides java.util.logging.LogManager.addLogger.

Doc from java.util.logging.LogManager.addLogger.

Add a named logger. This does nothing and returns false if a logger with the same name is already registered.

The Logger factory methods call this method to register each newly created Logger.

The application should retain its own reference to the Logger object to avoid it being garbage collected. The LogManager may only retain a weak reference.

Parameters
logger:Logger

the new logger.

Returns:boolean

true if the argument logger was registered successfully, false if a logger of that name already exists.

Annotations
@Override
getLoggerback to summary
public Logger getLogger(final String name)

Overrides java.util.logging.LogManager.getLogger.

Doc from java.util.logging.LogManager.getLogger.

Method to find a named logger.

Note that since untrusted code may create loggers with arbitrary names this method should not be relied on to find Loggers for security sensitive logging. It is also important to note that the Logger associated with the String name may be garbage collected at any time if there is no strong reference to the Logger. The caller of this method must check the return value for null in order to properly handle the case where the Logger has been garbage collected.

Parameters
name:String

name of the logger

Returns:Logger

matching logger or null if none is found

Annotations
@Override
getLoggerNamesback to summary
public Enumeration<String> getLoggerNames()

Overrides java.util.logging.LogManager.getLoggerNames.

Doc from java.util.logging.LogManager.getLoggerNames.

Get an enumeration of known logger names.

Note

Loggers may be added dynamically as new classes are loaded. This method only reports on the loggers that are currently registered. It is also important to note that this method only returns the name of a Logger, not a strong reference to the Logger itself. The returned String does nothing to prevent the Logger from being garbage collected. In particular, if the returned name is passed to LogManager.getLogger(), then the caller must check the return value from LogManager.getLogger() for null to properly handle the case where the Logger has been garbage collected in the time since its name was returned by this method.

Returns:Enumeration<String>

enumeration of logger name strings

Annotations
@Override