ServiceLoader based
discovery mechanism with a default of using JDK based logging. An
implementation that uses the full Commons Logging discovery mechanism is
available as part of the Tomcat extras download.
Why? It is an attempt to strike a balance between simpler code (no discovery)
and providing flexibility - particularly for those projects that embed Tomcat
or some of Tomcat's components - is an alternative logging
implementation is desired.
Note that this implementation is not just a wrapper around JDK logging (like
the original commons-logging impl). It adds 2 features - a simpler
configuration (which is in fact a subset of log4j.properties) and a
formatter that is less ugly.
The removal of 'abstract' preserves binary backward compatibility. It is
possible to preserve the abstract - and introduce another (hardcoded) factory
- but I see no benefit.
Since this class is not intended to be extended - all protected methods are
removed. This can be changed - but again, there is little value in keeping
dead code. Just take a quick look at the removed code ( and it's complexity).
--------------
Original comment:
Factory for creating Log instances, with discovery and
configuration features similar to that employed by standard Java APIs
such as JAXP.
Implementation Note
- This implementation is heavily based on the SAXParserFactory and DocumentBuilderFactory implementations (corresponding to the JAXP pluggability APIs) found in Apache Xerces.
| Modifier and Type | Field and Description |
|---|---|
| private final Constructor | |
| private static final LogFactory |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static LogFactory | Returns: The singleton LogFactory instanceConstruct (if necessary) and return a |
| public Log | Returns: A log instance with the requested nameLogical name of the name)Log instance to be
returned (the meaning of this name is only known to the underlying
logging implementation that is being wrapped)Construct (if necessary) and return a |
| public Log | Returns: A log instance with a name of clazz.getName()Class for which a suitable Log name will be derived clazz)Convenience method to derive a name from the specified class and
call |
| public static Log | |
| public static Log | Returns: A log instance with the requested nameLogical name of the name)Log instance to be
returned (the meaning of this name is only known to the underlying
logging implementation that is being wrapped)Convenience method to return a named logger, without the application having to care about factories. |
| public static void | release(ClassLoader
ClassLoader for which to release the LogFactory classLoader)Release any internal references to previously created |
| discoveredLogConstructor | back to summary |
|---|---|
| private final Constructor<? extends Log> discoveredLogConstructor | |
| singleton | back to summary |
|---|---|
| private static final LogFactory singleton | |
| LogFactory | back to summary |
|---|---|
| private LogFactory() Private constructor that is not available for public use. | |
| getFactory | back to summary |
|---|---|
| public static LogFactory getFactory() throws LogConfigurationException Construct (if necessary) and return a
Note - If the properties file method of identifying the
| |
| getInstance | back to summary |
|---|---|
| public Log getInstance(String name) throws LogConfigurationException Construct (if necessary) and return a Note - Depending upon the implementation of
the
| |
| getInstance | back to summary |
|---|---|
| public Log getInstance(Class<?> clazz) throws LogConfigurationException Convenience method to derive a name from the specified class and
call
| |
| getLog | back to summary |
|---|---|
| public static Log getLog(Class<?> clazz) throws LogConfigurationException Convenience method to return a named logger, without the application having to care about factories.
| |
| getLog | back to summary |
|---|---|
| public static Log getLog(String name) throws LogConfigurationException Convenience method to return a named logger, without the application having to care about factories.
| |
| release | back to summary |
|---|---|
| public static void release(ClassLoader classLoader) Release any internal references to previously created
| |