mazz.i18n
Class LoggerFactory

java.lang.Object
  extended by mazz.i18n.LoggerFactory

public class LoggerFactory
extends java.lang.Object

Factory used to create the I18N Logger objects. Note that if you pass to a method a null value for a logger's locale (or you call a method where Locale is not specified as an argument), then the default locale to be used will be determined by the LoggerLocale object.

To tell this factory what types of loggers to create, set the system property i18nlog.logger-type to one of the following:

log4j is to indicate that Apache Log4J is to be used directly as the underlying logging framework; commons is to indicate the use of Apache Commons Logging and jdk is to indicate that the JDK Logging API is to be used.

If this system property is not set, Apache Log4J will be used directly if it is found in this class's class loader. If that is not found, Apache Commons Logging will be used if it is found in this class's class loader. Otherwise, JDK Logging will be used.

You can programatically set the logger type this factory will use by calling resetLoggerType(mazz.i18n.LoggerFactory.LoggerType).

Version:
$Revision: 1.3 $
Author:
John Mazzitelli
See Also:
Logger, LoggerLocale

Nested Class Summary
static class LoggerFactory.LoggerType
          Enum of the different types of loggers.
 
Field Summary
static java.lang.String SYSPROP_LOGGER_TYPE
          The system property whose value determines the type of loggers this factory creates.
 
Method Summary
static Logger getLogger(java.lang.Class clazz)
          Creates a new Logger object using a default resource bundle and the JVM's default locale.
static Logger getLogger(java.lang.Class clazz, java.util.Locale locale)
          Creates a new Logger object using a default resource bundle.
static Logger getLogger(java.lang.Class clazz, Msg.BundleBaseName basename)
          Creates a new Logger object using the JVM's default locale.
static Logger getLogger(java.lang.Class clazz, Msg.BundleBaseName basename, java.util.Locale locale)
          Creates a new Logger object.
static Logger getLogger(java.lang.String name)
          Creates a new Logger object using a default resource bundle and the JVM's default locale.
static Logger getLogger(java.lang.String name, java.util.Locale locale)
          Creates a new Logger object using a default resource bundle.
static Logger getLogger(java.lang.String name, Msg.BundleBaseName basename)
          Creates a new Logger object using the JVM's default locale.
static Logger getLogger(java.lang.String name, Msg.BundleBaseName basename, java.util.Locale locale)
          Creates a new Logger object.
static LoggerFactory.LoggerType resetLoggerType(LoggerFactory.LoggerType type)
          Resets the logger type that this factory will use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SYSPROP_LOGGER_TYPE

public static final java.lang.String SYSPROP_LOGGER_TYPE
The system property whose value determines the type of loggers this factory creates.

See Also:
Constant Field Values
Method Detail

getLogger

public static Logger getLogger(java.lang.String name,
                               Msg.BundleBaseName basename,
                               java.util.Locale locale)
Creates a new Logger object.

Parameters:
name - the name to give to the logger (this is usually a class name of the object that will be logging messages)
basename - the base bundle name used to identify the resource bundle to use (may be null)
locale - the locale of the messages that will be logged (may be null)
Returns:
the new logger that was created
See Also:
Msg.Msg(Msg.BundleBaseName, Locale)

getLogger

public static Logger getLogger(java.lang.Class clazz,
                               Msg.BundleBaseName basename,
                               java.util.Locale locale)
Creates a new Logger object.

Parameters:
clazz - the class of the object that will be logging messages
basename - the base bundle name used to identify the resource bundle to use
locale - the locale of the messages that will be logged (used to further identify the resource bundle)
Returns:
the new logger that was created
See Also:
Msg.Msg(Msg.BundleBaseName, Locale)

getLogger

public static Logger getLogger(java.lang.String name,
                               Msg.BundleBaseName basename)
Creates a new Logger object using the JVM's default locale.

Parameters:
name - the name to give to the logger (this is usually a class name of the object that will be logging messages)
basename - the base bundle name used to identify the resource bundle to use
Returns:
the new logger that was created
See Also:
Msg.Msg(Msg.BundleBaseName)

getLogger

public static Logger getLogger(java.lang.Class clazz,
                               Msg.BundleBaseName basename)
Creates a new Logger object using the JVM's default locale.

Parameters:
clazz - the class of the object that will be logging messages
basename - the base bundle name used to identify the resource bundle to use
Returns:
the new logger that was created
See Also:
Msg.Msg(Msg.BundleBaseName)

getLogger

public static Logger getLogger(java.lang.String name,
                               java.util.Locale locale)
Creates a new Logger object using a default resource bundle.

Parameters:
name - the name to give to the logger (this is usually a class name of the object that will be logging messages)
locale - the locale of the messages that will be logged (used to further identify the resource bundle)
Returns:
the new logger that was created
See Also:
Msg.Msg(Locale)

getLogger

public static Logger getLogger(java.lang.Class clazz,
                               java.util.Locale locale)
Creates a new Logger object using a default resource bundle.

Parameters:
clazz - the class of the object that will be logging messages
locale - the locale of the messages that will be logged (used to further identify the resource bundle)
Returns:
the new logger that was created
See Also:
Msg.Msg(Locale)

getLogger

public static Logger getLogger(java.lang.String name)
Creates a new Logger object using a default resource bundle and the JVM's default locale.

Parameters:
name - the name to give to the logger (this is usually a class name of the object that will be logging messages)
Returns:
the new logger that was created
See Also:
Msg.Msg()

getLogger

public static Logger getLogger(java.lang.Class clazz)
Creates a new Logger object using a default resource bundle and the JVM's default locale.

Parameters:
clazz - the class of the object that will be logging messages
Returns:
the new logger that was created
See Also:
Msg.Msg()

resetLoggerType

public static LoggerFactory.LoggerType resetLoggerType(LoggerFactory.LoggerType type)
Resets the logger type that this factory will use. If type is null, the system property SYSPROP_LOGGER_TYPE will be examined to determine what logger type to use (and if that isn't set, JDK logging will be used unless Apache Log4J or Apache Commons logging is found in the class's classloader, checked in that order).

Parameters:
type - the new logger type that will be used when creating loggers; if null will use heuristics to guess what logger type to use
Returns:
the logger type that is to be used (useful if null was passed in and the caller wants to know what will be used)


Copyright © 2006 John J. Mazzitelli All Rights Reserved. Licensed under LGPL