org.webdocwf.util.loader.logging
Class Logger

java.lang.Object
  extended byorg.webdocwf.util.loader.logging.Logger
Direct Known Subclasses:
StandardLogger

public abstract class Logger
extends java.lang.Object

A general-purpose logging facility. It is modeled after syslogd. This is a base class from which an actual implementation is derived. It only defines how log message are written by a client. Where the log message is written and the mechanism for controlling logging is left up to the implementation. This class does not define any of these mechanism and their definition is not necessary for understand how to use this class.

Each log message is associate with a facility and has a level assigned to it. A facility is a symbolic (String) name that defines a class of log messages. A level is used to indicate the It is expected that the implementation can enable, disable and direct log messages based on these attributes. Facilities and levels are defined symbolicly, with no restriction on the name, and form a tuple. Several standard levels are defined as integer constants and their use is expected to be higher performing than symbolic levels..

Normally, a single, global instance of the object is exists and is obtainable by a static method in this class.

Log messages are written via an object implementing LogChannel. A channel is associated with a single facility, with the level being specified when a message is written. Normally, a LogChannel is obtained once at initialization time and use repeatedly. It is permissible to obtain multiple references to the log channel for a facility, but this is discouraged for performance reasons.

Log messages, even debugging ones, should be defined with care. They should be terse, but clear to someone who isn't intimately familiar with the code. Permanent debugging messages should be designed with the idea of use when supportting a deployed product.

The central logging object needs to be configured very early in the startup process. If logging can't be configured, then the startup should be aborted or a object created that does some simple form of logging, such as write to stderr. A client should never have to check if the global logger object exists.


Field Summary
protected static Logger centralLogger
          Global Logger object.
 boolean[] enbledLogLevels
           
static int LOGMODE_FULL
          Critical conditions.
static int LOGMODE_NONE
          A condition that should be corrected immediately
static int LOGMODE_NORMAL
          Standard level.
protected static java.lang.String[] standardLevelNames
          Table of standard level names
static java.lang.String strLOGMODE_FULL
           
static java.lang.String strLOGMODE_NONE
           
static java.lang.String strLOGMODE_NORMAL
           
 
Constructor Summary
Logger()
           
 
Method Summary
abstract  void close()
           
abstract  void configure(java.lang.String confFilePath)
          Configure Logger with given config file, interpreting of config file is logger implementation specific.
static Logger getCentralLogger()
          Get the central (global) logging object.
abstract  boolean[] getEnabledLogLevels()
           
abstract  int getLevel(java.lang.String level)
          Convert a symbolic level to an integer identifier.
abstract  java.lang.String getMessage(java.lang.String key)
           
abstract  boolean isEnabled(int level)
          Determine if logging is enabled for the specified level.
abstract  boolean isEnabled(java.lang.String level)
          Determine if logging is enabled for the specified level.
abstract  void setEnabledLogLevels(java.lang.String logMode)
           
abstract  boolean setMessage(java.lang.String key, java.lang.String value)
           
abstract  void write(int level, java.lang.String msg)
          Write a string to the log file.
abstract  void write(int level, java.lang.String msg, java.lang.Throwable throwable)
          Write a string and exception to the log file.
abstract  void write(java.lang.String level, java.lang.String msg)
          Write a string to the log file.
abstract  void write(java.lang.String level, java.lang.String msg, java.lang.Throwable throwable)
          Write a string and exception to the log file.
abstract  boolean writeEcho(java.lang.String strLogTxt)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGMODE_NORMAL

public static final int LOGMODE_NORMAL
Standard level.

See Also:
Constant Field Values

LOGMODE_NONE

public static final int LOGMODE_NONE
A condition that should be corrected immediately

See Also:
Constant Field Values

LOGMODE_FULL

public static final int LOGMODE_FULL
Critical conditions.

See Also:
Constant Field Values

strLOGMODE_NONE

public static final java.lang.String strLOGMODE_NONE
See Also:
Constant Field Values

strLOGMODE_NORMAL

public static final java.lang.String strLOGMODE_NORMAL
See Also:
Constant Field Values

strLOGMODE_FULL

public static final java.lang.String strLOGMODE_FULL
See Also:
Constant Field Values

enbledLogLevels

public boolean[] enbledLogLevels

centralLogger

protected static Logger centralLogger
Global Logger object.


standardLevelNames

protected static final java.lang.String[] standardLevelNames
Table of standard level names

Constructor Detail

Logger

public Logger()
Method Detail

getCentralLogger

public static Logger getCentralLogger()
Get the central (global) logging object.

Returns:
A reference the object. If the facility has not been initialized null is returned. However, this is considered a bug in the design of the initialization. Clients do not need to check for null.

configure

public abstract void configure(java.lang.String confFilePath)
                        throws java.lang.Exception
Configure Logger with given config file, interpreting of config file is logger implementation specific.

Parameters:
confFilePath - Path to configuration file.
Throws:
java.lang.Exception

isEnabled

public abstract boolean isEnabled(int level)
Determine if logging is enabled for the specified level. This is useful to prevent a series of unnecessary logging calls, as often encountered with debug logging, or a call where generating the message is expensive.

Parameters:
level - Numeric level that is to be checked.
Returns:
true if enabled, false if not enabled.

isEnabled

public abstract boolean isEnabled(java.lang.String level)
Determine if logging is enabled for the specified level. This is useful to prevent a series of unnecessary logging calls, as often encountered with debug logging, or a call where generating the message is expensive.

Parameters:
level - Symbolic level that is to be checked.
Returns:
true if enabled, false if not enabled.

getLevel

public abstract int getLevel(java.lang.String level)
Convert a symbolic level to an integer identifier.

Parameters:
level - Symbolic level to convert
Returns:
The numeric level identifier

write

public abstract void write(int level,
                           java.lang.String msg)
Write a string to the log file.

Parameters:
level - Numeric level the message is associated with.
msg - The message to log.

write

public abstract void write(java.lang.String level,
                           java.lang.String msg)
Write a string to the log file.

Parameters:
level - Symbolic level the message is associated with.
msg - The message to log.

write

public abstract void write(int level,
                           java.lang.String msg,
                           java.lang.Throwable throwable)
Write a string and exception to the log file.

Parameters:
level - Numeric level the message is associated with.
msg - The message to log.
throwable - Exception or error to log.

write

public abstract void write(java.lang.String level,
                           java.lang.String msg,
                           java.lang.Throwable throwable)
Write a string and exception to the log file.

Parameters:
level - Symbolic level the message is associated with.
msg - The message to log.
throwable - Exception or error to log.

getEnabledLogLevels

public abstract boolean[] getEnabledLogLevels()

setEnabledLogLevels

public abstract void setEnabledLogLevels(java.lang.String logMode)

setMessage

public abstract boolean setMessage(java.lang.String key,
                                   java.lang.String value)

getMessage

public abstract java.lang.String getMessage(java.lang.String key)

writeEcho

public abstract boolean writeEcho(java.lang.String strLogTxt)

close

public abstract void close()


Copyright © 2002-2007 Together - the Workgroup. All Rights Reserved.