Package org.apache.commons.logging.impl
Class Log4jApiLogFactory
- java.lang.Object
-
- org.apache.commons.logging.LogFactory
-
- org.apache.commons.logging.impl.Log4jApiLogFactory
-
public final class Log4jApiLogFactory extends LogFactory
Logger factory hardcoded to send everything to Log4j API.Based on the `log4j-jcl` artifact from Apache Logging Services.
- Since:
- 1.3.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classLog4jApiLogFactory.Log4j2Logprivate static classLog4jApiLogFactory.LogAdapter
-
Field Summary
Fields Modifier and Type Field Description private org.apache.logging.log4j.spi.LoggerAdapter<Log>adapterCaches Log instancesprivate java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.Object>attributesprivate static java.lang.String[]EMPTY_ARRAYprivate static org.apache.logging.log4j.MarkerMARKERMarker used by all messages coming from Apache Commons Logging.-
Fields inherited from class org.apache.commons.logging.LogFactory
DIAGNOSTICS_DEST_PROPERTY, factories, FACTORY_DEFAULT, FACTORY_PROPERTIES, FACTORY_PROPERTY, HASHTABLE_IMPLEMENTATION_PROPERTY, nullClassLoaderFactory, PRIORITY_KEY, SERVICE_ID, TCCL_KEY
-
-
Constructor Summary
Constructors Constructor Description Log4jApiLogFactory()Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectgetAttribute(java.lang.String name)Gets the configuration attribute with the specified name (if any), ornullif there is no such attribute.java.lang.String[]getAttributeNames()Gets an array containing the names of all currently defined configuration attributes.LoggetInstance(java.lang.Class<?> clazz)Gets a Log for the given class.LoggetInstance(java.lang.String name)Gets a (possibly new)Loginstance, using the factory's current set of configuration attributes.voidrelease()This method is supposed to clear all loggers.voidremoveAttribute(java.lang.String name)Removes any configuration attribute associated with the specified name.voidsetAttribute(java.lang.String name, java.lang.Object value)Sets the configuration attribute with the specified name.-
Methods inherited from class org.apache.commons.logging.LogFactory
createFactory, directGetContextClassLoader, getClassLoader, getContextClassLoader, getFactory, getLog, getLog, handleThrowable, isDiagnosticsEnabled, logRawDiagnostic, newFactory, newFactory, objectId, release, releaseAll
-
-
-
-
Field Detail
-
EMPTY_ARRAY
private static final java.lang.String[] EMPTY_ARRAY
-
MARKER
private static final org.apache.logging.log4j.Marker MARKER
Marker used by all messages coming from Apache Commons Logging.
-
adapter
private final org.apache.logging.log4j.spi.LoggerAdapter<Log> adapter
Caches Log instances
-
attributes
private final java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.Object> attributes
-
-
Method Detail
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
Description copied from class:LogFactoryGets the configuration attribute with the specified name (if any), ornullif there is no such attribute.- Specified by:
getAttributein classLogFactory- Parameters:
name- Name of the attribute to return- Returns:
- the configuration attribute with the specified name.
-
getAttributeNames
public java.lang.String[] getAttributeNames()
Description copied from class:LogFactoryGets an array containing the names of all currently defined configuration attributes. If there are no such attributes, a zero length array is returned.- Specified by:
getAttributeNamesin classLogFactory- Returns:
- an array containing the names of all currently defined configuration attributes
-
getInstance
public Log getInstance(java.lang.Class<?> clazz)
Description copied from class:LogFactoryGets a Log for the given class.- Specified by:
getInstancein classLogFactory- Parameters:
clazz- Class for which a suitable Log name will be derived- Returns:
- a name from the specified class.
-
getInstance
public Log getInstance(java.lang.String name)
Description copied from class:LogFactoryGets a (possibly new)Loginstance, using the factory's current set of configuration attributes.NOTE - Depending upon the implementation of the
LogFactoryyou are using, theLoginstance you are returned may or may not be local to the current application, and may or may not be returned again on a subsequent call with the same name argument.- Specified by:
getInstancein classLogFactory- Parameters:
name- Logical name of theLoginstance to be returned (the meaning of this name is only known to the underlying logging implementation that is being wrapped)- Returns:
- a
Loginstance.
-
release
public void release()
This method is supposed to clear all loggers. In this implementation it will clear all the logger wrappers but the loggers managed by the underlying logger context will not be.- Specified by:
releasein classLogFactory
-
removeAttribute
public void removeAttribute(java.lang.String name)
Description copied from class:LogFactoryRemoves any configuration attribute associated with the specified name. If there is no such attribute, no action is taken.- Specified by:
removeAttributein classLogFactory- Parameters:
name- Name of the attribute to remove
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)Description copied from class:LogFactorySets the configuration attribute with the specified name. Calling this with anullvalue is equivalent to callingremoveAttribute(name).- Specified by:
setAttributein classLogFactory- Parameters:
name- Name of the attribute to setvalue- Value of the attribute to set, ornullto remove any setting for this attribute
-
-