org.eclipse.datatools.connectivity.oda.util.logging
Class LogManager

java.lang.Object
  extended by org.eclipse.datatools.connectivity.oda.util.logging.LogManager

public class LogManager
extends java.lang.Object

LogManager is a static class that maintains a set of named Loggers. It provides the interface to create named Loggers and to retrieve the loggers for logging purposes.


Method Summary
static Logger createLogger(java.lang.String loggerName, int logLevel, java.lang.String logDirectory, java.lang.String logPrefix, java.lang.String formatterClassName)
          Creates a named Logger with the specified log configuration.
static Logger createLogger(java.lang.String loggerName, int logLevel, java.lang.String logDirectory, java.lang.String logPrefix, java.lang.String formatterClassName, boolean isManaged)
          Creates a named Logger with the specified log configuration.
static Logger getLogger(java.lang.String loggerName)
          Gets a previously created Logger by name.
static Logger getLogger(java.lang.String loggerName, int logLevel, java.lang.String logDirectory, java.lang.String logPrefix, java.lang.String formatterClassName)
          Creates a named Logger with the specified log configuration information, if the named Logger doesn't already exist.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createLogger

public static Logger createLogger(java.lang.String loggerName,
                                  int logLevel,
                                  java.lang.String logDirectory,
                                  java.lang.String logPrefix,
                                  java.lang.String formatterClassName)
Creates a named Logger with the specified log configuration. The specified logger name should be specific to the application using the logging framework to prevent name collision in the logger namespace, since multiple loggers under this management cannot have the same logger name.

Parameters:
loggerName - the name of the logger to be created
logLevel - the logger log level
logDirectory - the required directory to store the logs
logPrefix - the required file name prefix of the log file name; the format will be <logPrefix>-YYMMDD-hhmmss.log
formatterClassName - a LogFormatter class name; if this is null or empty, the default LogFormatter will be used. The customized log formatter must inherit from org.eclipse.datatools.connectivity.oda.logging.LogFormatter and implements the format() method
Returns:
the constructed named Logger
Throws:
java.lang.IllegalArgumentException - if logger with the same name already exists.
See Also:
createLogger(String, int, String, String, String, boolean)

createLogger

public static Logger createLogger(java.lang.String loggerName,
                                  int logLevel,
                                  java.lang.String logDirectory,
                                  java.lang.String logPrefix,
                                  java.lang.String formatterClassName,
                                  boolean isManaged)
Creates a named Logger with the specified log configuration.

Parameters:
loggerName - the name of the logger to be created
logLevel - the logger log level
logDirectory - the required directory to store the logs
logPrefix - the required file name prefix of the log file name
formatterClassName - a LogFormatter class name
isManaged - indicates whether the created logger should be managed by this; if true, the logger name must be unique and the logger instance can be obtained by getLogger(String); if false, this does not maintain a reference to the created logger
Returns:
the constructed named Logger
Throws:
java.lang.IllegalArgumentException - if logger is to be managed and the same name already exists.
Since:
3.2 (DTP 1.7)
See Also:
createLogger(String, int, String, String, String)

getLogger

public static Logger getLogger(java.lang.String loggerName,
                               int logLevel,
                               java.lang.String logDirectory,
                               java.lang.String logPrefix,
                               java.lang.String formatterClassName)
Creates a named Logger with the specified log configuration information, if the named Logger doesn't already exist. If the named Logger already exists, then it will be updated the specified log configuration. If the specified log level or the formatter class is different, then the new values will be set while maintaining the same log file. If either the log directory or the log prefix has changed, then a new log file will be created.

Parameters:
loggerName - the name of the logger to be created or updated.
logLevel - the logger log level.
logDirectory - the required directory to store the logs.
logPrefix - the required file name prefix of the log file name; the format will be <logPrefix>-YYMMDD-hhmmss.log.
formatterClassName - a LogFormatter class name; if this is null or empty, the default LogFormatter will be used. The customized log formatter must inherit from org.eclipse.datatools.connectivity.oda.logging.LogFormatter and implements the format() method.
Returns:
the constructed or updated named Logger.

getLogger

public static Logger getLogger(java.lang.String loggerName)
Gets a previously created Logger by name. The specified name must be the same name used in the createLogger() method.

Parameters:
loggerName - the logger's name.
Returns:
the Logger associated with the name; null if no Logger is associated with the specified name.