public class AndroidLogFactoryImpl extends AndroidLogFactory
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,Object> |
attributes
Configuration attributes.
|
protected Map<String,Logger> |
instances
The
Logger instances that have already been created, keyed by logger name. |
static String |
LOG_PROPERTY
The name (
org.apache.commons.logging.AndroidLog) of the system property identifying our AndroidLog implementation class. |
protected Constructor<?> |
logConstructor
The one-argument constructor of the
Logger implementation class that will be used to create new
instances. |
protected Class<?>[] |
logConstructorSignature
The signature of the Constructor to be used.
|
protected Method |
logMethod
The one-argument
setLogFactory method of the selected Logger method, if it exists. |
protected Class<?>[] |
logMethodSignature
The signature of the
setLogFactory method to be used. |
DIAGNOSTICS_DEST_PROPERTY, factories, FACTORY_DEFAULT, FACTORY_PROPERTIES, FACTORY_PROPERTY, PRIORITY_KEY| Constructor and Description |
|---|
AndroidLogFactoryImpl() |
| Modifier and Type | Method and Description |
|---|---|
Object |
getAttribute(String name)
Return the configuration attribute with the specified name (if any), or
null if there is no such attribute. |
String[] |
getAttributeNames()
Return an array containing the names of all currently defined configuration attributes.
|
Logger |
getInstance(String name)
Construct (if necessary) and return a
Logger instance, using the factory's current set of configuration attributes. |
protected void |
logDiagnostic(String msg)
Output a diagnostic message to a user-specified destination (if the user has enabled diagnostic logging).
|
protected Logger |
newInstance(String name)
Create and return a new
Logger instance for the specified name. |
void |
release()
Release any internal references to previously created
Logger instances returned by this factory. |
void |
removeAttribute(String name)
Remove any configuration attribute associated with the specified name.
|
void |
setAttribute(String name,
Object value)
Set the configuration attribute with the specified name.
|
createFactory, getClassLoader, getFactory, getLog, isDiagnosticsEnabled, logRawDiagnostic, newFactory, objectId, release, releaseAllpublic static final String LOG_PROPERTY
org.apache.commons.logging.AndroidLog) of the system property identifying our AndroidLog implementation class.protected Map<String,Logger> instances
Logger instances that have already been created, keyed by logger name.protected Constructor<?> logConstructor
Logger implementation class that will be used to create new
instances. This value is initialized by getLogConstructor(), and then returned repeatedly.protected Class<?>[] logConstructorSignature
protected Method logMethod
setLogFactory method of the selected Logger method, if it exists.protected Class<?>[] logMethodSignature
setLogFactory method to be used.protected void logDiagnostic(String msg)
msg - diagnostic messagepublic Object getAttribute(String name)
null if there is no such attribute.getAttribute in class AndroidLogFactoryname - Name of the attribute to returnpublic String[] getAttributeNames()
getAttributeNames in class AndroidLogFactorypublic Logger getInstance(String name) throws LogConfigurationException
Construct (if necessary) and return a Logger instance, using the factory's current set of configuration attributes.
NOTE - Depending upon the implementation of the AndroidLogFactory you are using, the Logger
instance 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.
getInstance in class AndroidLogFactoryname - Logical name of the Logger instance to be returned (the meaning of this name is only known to the underlying
logging implementation that is being wrapped)LogConfigurationException - if a suitable Logger instance cannot be returnedpublic void release()
Logger instances returned by this factory. This is
useful in environments like servlet containers, which implement application reloading by throwing away a ClassLoader. Dangling references to
objects in that class loader would prevent garbage collection.release in class AndroidLogFactorypublic void removeAttribute(String name)
removeAttribute in class AndroidLogFactoryname - Name of the attribute to removepublic void setAttribute(String name, Object value)
null value is equivalent to calling
removeAttribute(name).
This method can be used to set logging configuration programmatically rather than via system properties. It can also be used in code running within a container (such as a webapp) to configure behaviour on a per-component level instead of globally as system properties would do. To use this method instead of a system property, call
AndroidLogFactory.getFactory().setAttribute(...)This must be done before the first Logger object is created; configuration changes after that point will be ignored.
This method is also called automatically if AndroidLogFactory detects a commons-logging.properties file; every entry in that file is set automatically as an attribute here.
setAttribute in class AndroidLogFactoryname - Name of the attribute to setvalue - Value of the attribute to set, or null to remove any setting for this attributeprotected Logger newInstance(String name) throws LogConfigurationException
Logger instance for the specified name.name - Name of the new loggerLogConfigurationException - if a new instance cannot be createdCopyright © 2014–2015 Tomas Teubner. All rights reserved.