com.partnersoft.core
Class LogFactory

java.lang.Object
  extended by com.partnersoft.core.LogFactory
Direct Known Subclasses:
Log4jLogFactory, WebstartLogFactory

public abstract class LogFactory
extends java.lang.Object

Standard, class-specific logging facility.

This facility, and the related Log, are designed to insulate Partner code from the specific logging API used. See Log for a more complete description.

The interface for this class was largely copied from the class of the same name in the jakarta commons logging project. However it does not internally depend upon reflection, custom class loaders, or any other advanced JVM tricks not available on limited platforms like J2ME. It is much simpler - it assumes the application initialization code has set a default factory.

This class is designed to be extended. Subclasses adapt the generic interface to a specific logging implementation, handing out instances of Log.

Copyright 2006 Partner Software, Inc.

Version:
$Id: LogFactory.java 1012 2007-11-24 18:30:02Z paul $
Author:
Paul Reavis, Russell Cagle

Constructor Summary
protected LogFactory()
          Protected constructor that is not available for public use.
 
Method Summary
static LogFactory getFactory()
          Gets the default LogFactory implementation.
 Log instanceFor(java.lang.Class clazz)
          Return a Log object for the given class.
abstract  Log instanceFor(java.lang.String name)
          Returns the correct Log instance for the given name.
static Log logFor(java.lang.Class clazz)
          Convenience method to return a named logger, without the application having to care about factories.
static Log logFor(java.lang.String name)
          Convenience method to return a named logger, without the application having to care about factories.
static void setFactory(LogFactory newDefault)
          Sets the default LogFactory implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogFactory

protected LogFactory()
Protected constructor that is not available for public use.

Method Detail

getFactory

public static LogFactory getFactory()
Gets the default LogFactory implementation.


setFactory

public static void setFactory(LogFactory newDefault)
Sets the default LogFactory implementation.


logFor

public static Log logFor(java.lang.Class clazz)
Convenience method to return a named logger, without the application having to care about factories.

Parameters:
clazz - Class from which a log name will be derived
Throws:
org.apache.commons.logging.LogConfigurationException - if a suitable Log instance cannot be returned

logFor

public static Log logFor(java.lang.String name)
Convenience method to return a named logger, without the application having to care about factories.

Parameters:
name - Logical name of the Log instance to be returned (the meaning of this name is only known to the underlying logging implementation that is being wrapped)
Throws:
org.apache.commons.logging.LogConfigurationException - if a suitable Log instance cannot be returned

instanceFor

public Log instanceFor(java.lang.Class clazz)
Return a Log object for the given class. By default just calls instanceFor(class.getName());


instanceFor

public abstract Log instanceFor(java.lang.String name)
Returns the correct Log instance for the given name.