diff --git a/xdocs/guide.xml b/xdocs/guide.xml index 87eb30b..70d429a 100644 --- a/xdocs/guide.xml +++ b/xdocs/guide.xml @@ -95,8 +95,8 @@ a specific logging implementation.

JCL provides thin-wrapper Log implementations for other logging tools, including Log4J, -Avalon LogKit, -the Avalon Framework's logging infrastructure, +Avalon LogKit +(the Avalon Framework's logging infrastructure), JDK 1.4, and an implementation of JDK 1.4 logging APIs (JSR-47) for pre-1.4 systems. The interface maps closely to Log4J and LogKit. @@ -117,9 +117,10 @@ need to do any configuration at all!

There are two base abstractions used by JCL: Log (the basic logger) and LogFactory (which knows how to create Log -instances). Using LogFactory implementations other than the default is a -subject for advanced users only, so let's concentrate on configuring the default -implementation. +instances). Specifying a particular Log implementation is very useful (whether that is +one provided by commons-logging or a user-defined one). Specifying a +LogFactory implementation other than the default is a subject for +advanced users only, so will not be addressed here.

The default LogFactory implementation uses the following discovery process @@ -130,9 +131,23 @@ to determine what type of Log implementation it should use

  1. Look for a configuration attribute of this factory named -org.apache.commons.logging.Log (for backwards -compatibility to pre-1.0 versions of this API, an attribute +org.apache.commons.logging.Log (for backwards compatibility to +pre-1.0 versions of this API, an attribute org.apache.commons.logging.log is also consulted). +

    +Configuration attributes can be set explicitly by java code, but they are more +commonly set by placing a file named commons-logging.properties in the classpath. +When such a file exists, every entry in the properties file becomes an "attribute" +of the LogFactory. When there is more than one such file in the classpath, releases +of commons-logging prior to 1.1 simply use the first one found. From release 1.1, +each file may define a priority key in each file, and the file with +the highest priority is used (no priority definition implies priority of zero). +When multiple files have the same priority, the first one found is used. +

    +

    +Defining this property in a commons-logging.properties file is the recommended +way of explicitly selecting a Log implementation. +

  2. Look for a system property named @@ -262,11 +277,20 @@ For each class definition, declare and initialize a public class CLASS { - private static Log log = LogFactory.getLog(CLASS.class); + private Log log = LogFactory.getLog(CLASS.class); ... ; +

    +Note that for application code, declaring the log member as "static" is more +efficient as one Log object is created per class, and is recommended. +However this is not safe to do for a class which may be deployed via a "shared" +classloader in a servlet or j2ee container or similar environment. If the class +may end up invoked with different thread-context-classloader values set then the +member must not be declared static. The use of "static" should therefore +be avoided in code within any "library" type project. +

    Messages are logged to a logger, such as log by invoking a method corresponding to priority.