Concrete subclass of com.good.gd.apache.commons.logging.LogFactory that implements the following algorithm to dynamically select a logging implementation class to instantiate a wrapper for.
-
Use a factory configuration attribute named
org.apache.commons.logging.Log
to identify the requested implementation class.
-
Use the
org.apache.commons.logging.Log
system property to identify the requested implementation class.
-
If Log4J is available, return an instance of
org.apache.commons.logging.impl.Log4JLogger
.
-
If JDK 1.4 or later is available, return an instance of
org.apache.commons.logging.impl.Jdk14Logger
.
-
Otherwise, return an instance of
org.apache.commons.logging.impl.SimpleLog
.
If the selected com.good.gd.apache.commons.logging.Log implementation class has a setLogFactory()
method that accepts a com.good.gd.apache.commons.logging.LogFactory parameter, this method will be called on each newly created instance to identify the associated factory. This makes factory configuration attributes available to the Log instance, if it so desires.
This factory will remember previously created Log
instances for the same name, and will return them on repeated requests to the getInstance()
method.
- Author
- Rod Waldhoff
-
Craig R. McClanahan
-
Richard A. Sitze
-
Brian Stansberry
- Version
- Revision
- 399224
- Date
- 2006-05-03 10:25:54 +0100 (Wed, 03 May 2006)
Notice
The following notice applies to the original API on which this API is based, and to its documentation. The documentation of this API has been revised from the original.
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
|
static final String | LOG_PROPERTY |
| The name (org.apache.commons.logging.Log ) of the system property identifying our com.good.gd.apache.commons.logging.Log implementation class.
|
|
static final String | ALLOW_FLAWED_CONTEXT_PROPERTY |
| The name (org.apache.commons.logging.Log.allowFlawedContext ) of the system property which can be set true/false to determine system behaviour when a bad context-classloader is encountered. More...
|
|
static final String | ALLOW_FLAWED_DISCOVERY_PROPERTY |
| The name (org.apache.commons.logging.Log.allowFlawedDiscovery ) of the system property which can be set true/false to determine system behaviour when a bad logging adapter class is encountered during logging discovery. More...
|
|
static final String | ALLOW_FLAWED_HIERARCHY_PROPERTY |
| The name (org.apache.commons.logging.Log.allowFlawedHierarchy ) of the system property which can be set true/false to determine system behaviour when a logging adapter class is encountered which has bound to the wrong Log class implementation. More...
|
|
static final String | PRIORITY_KEY = "priority" |
| The name (priority ) of the key in the config file used to specify the priority of that particular config file. More...
|
|
static final String | TCCL_KEY = "use_tccl" |
| The name (use_tccl ) of the key in the config file used to specify whether logging classes should be loaded via the thread context class loader (TCCL), or not. More...
|
|
static final String | FACTORY_PROPERTY |
| The name (org.apache.commons.logging.LogFactory ) of the property used to identify the LogFactory implementation class name. More...
|
|
static final String | FACTORY_DEFAULT |
| The fully qualified class name of the fallback LogFactory implementation class to use, if no other can be found.
|
|
static final String | FACTORY_PROPERTIES |
| The name (commons-logging.properties ) of the properties file to search for.
|
|
static final String | DIAGNOSTICS_DEST_PROPERTY |
| The name (org.apache.commons.logging.diagnostics.dest ) of the property used to enable internal commons-logging diagnostic output, in order to get information on what logging implementations are being discovered, what classloaders they are loaded through, etc. More...
|
|
static final String | HASHTABLE_IMPLEMENTATION_PROPERTY |
|
|
static ClassLoader | getContextClassLoader () throws LogConfigurationException |
| Gets the context classloader. More...
|
|
static boolean | isDiagnosticsEnabled () |
| Workaround for bug in Java1.2; in theory this method is not needed. More...
|
|
static ClassLoader | getClassLoader (Class clazz) |
| Workaround for bug in Java1.2; in theory this method is not needed. More...
|
|
static ClassLoader | directGetContextClassLoader () throws LogConfigurationException |
| Return the thread context class loader if available; otherwise return null. More...
|
|
static LogFactory | newFactory (final String factoryClass, final ClassLoader classLoader, final ClassLoader contextClassLoader) throws LogConfigurationException |
| Return a new instance of the specified LogFactory implementation class, loaded by the specified class loader. More...
|
|
static LogFactory | newFactory (final String factoryClass, final ClassLoader classLoader) |
| Method provided for backwards compatibility; see newFactory version that takes 3 parameters. More...
|
|
static Object | createFactory (String factoryClass, ClassLoader classLoader) |
| Implements the operations described in the javadoc for newFactory. More...
|
|
static final void | logRawDiagnostic (String msg) |
| Write the specified message to the internal logging destination. More...
|
|
|
static LogFactory | getFactory () throws LogConfigurationException |
|
static Log | getLog (Class clazz) throws LogConfigurationException |
| Convenience method to return a named logger, without the application having to care about factories. More...
|
|
static Log | getLog (String name) throws LogConfigurationException |
| Convenience method to return a named logger, without the application having to care about factories. More...
|
|
static void | release (ClassLoader classLoader) |
| Release any internal references to previously created LogFactory instances that have been associated with the specified class loader (if any), after calling the instance method release() on each of them. More...
|
|
static void | releaseAll () |
| Release any internal references to previously created LogFactory instances, after calling the instance method release() on each of them. More...
|
|
static String | objectId (Object o) |
| Returns a string that uniquely identifies the specified object, including its class. More...
|
|
void setAttribute |
( |
String |
name, |
|
|
Object |
value |
|
) |
| |
Calling this with a 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
LogFactory.getFactory().setAttribute(...)
This must be done before the first Log object is created; configuration changes after that point will be ignored.
This method is also called automatically if LogFactory detects a commons-logging.properties file; every entry in that file is set automatically as an attribute here.
- Parameters
-
name | Name of the attribute to set |
value | Value of the attribute to set, or null to remove any setting for this attribute |
Reimplemented from LogFactory.