com.metamatrix.common.log
Class LogManager

java.lang.Object
  extended by com.metamatrix.common.log.LogManager

public final class LogManager
extends java.lang.Object

This class represents the interface to a single logging framework that is easily accessible by any component. Using the LogManager, a component can quickly submit a log message, and can rely upon the LogManager to determine (a) whether that message is to be recorded or discarded; and (b) where to send any recorded messages. Thus, the component's code that submits messages does not have to be modified to alter the logging behavior of the application.

By default, all context(s) are logged by the LogManager. The messages that the LogManager actually records and sends to the destinations can be controlled using two different and orthogonal parameters. The first is a message level that filters messages based upon detail, and the second is a message context that filters messages based upon origin. The LogManager tracks only those context(s) that should NOT be logged. Only if a message (which also is defined with these two parameters) passes both filters will it be sent to the destinations.

Each message is submitted with one of the following levels (determined by the particular method used to submit the message), sorted from the least detailed to the greatest:

  • Critical: This level of message is generally used to record an event or error that must be recorded (if any logging is used). If it is used to record an error, it generally means that the system encountered a critical error which affects the integrity, accuracy, reliability and/or capability of the system.
  • Error: Error messages are generally used to record unexpected problems, or errors that are not critical in nature and from which the system can automatically recover.
  • Warning: Warning messages generally described expected errors from which the system should recover. However, this level is used to record the fact that such an error or event did occur.
  • Information: This level of logging is the usually the normal level. All interesting periodic events should be logged at this level so someone looking through the log can see the amount and kind of processing happening in the system.
  • Detail: Such messages are moderately detailed, and help to debug typical problems in the system. Generally, these messages are not so detailed that the big picture gets lost.
  • Trace: A trace message is the most detailed logging level, used to trace system execution for really nasty problems. At this level, logging will be so verbose that the system performance may be affected.
  • The context for a message is any application-specified String. Again, only those message contexts that match those in the LogManager's configuration will be sent to the destinations.


    Constructor Summary
    LogManager()
               
     
    Method Summary
    static java.lang.Object createLoggingProxy(java.lang.String loggingContext, java.lang.Object instance, java.lang.Class[] interfaces, int level)
               
    static LogConfiguration getLogConfigurationCopy()
              Utility method to obtain the a modifiable log configuration for the LogManager.
    static boolean isMessageToBeRecorded(java.lang.String context, int msgLevel)
              Utility method to identify whether a log message with the specified context and level will be recorded in the LogManager's destinations.
    static void log(int msgLevel, java.lang.String context, java.lang.String message)
              Send a message of the specified level to the log.
    static void log(int msgLevel, java.lang.String context, java.lang.Throwable e, java.lang.String message)
              Send a message of the specified level to the log.
    static void logCritical(java.lang.String context, java.lang.String message)
              Send a critical message to the log.
    static void logCritical(java.lang.String context, java.lang.Throwable e, java.lang.String message)
              Send a critical message to the log.
    static void logDetail(java.lang.String context, java.lang.Object... msgParts)
              Send a detail message to the log.
    static void logDetail(java.lang.String context, java.lang.Throwable e, java.lang.String message)
              Send a detail message to the log.
    static void logError(java.lang.String context, java.lang.String message)
              Send an error message to the log.
    static void logError(java.lang.String context, java.lang.Throwable e, java.lang.String message)
              Send an error message to the log.
    static void logInfo(java.lang.String context, java.lang.String message)
              Send a information message to the log.
    static void logTrace(java.lang.String context, java.lang.Object... msgParts)
              Send a trace message to the log.
    static void logTrace(java.lang.String context, java.lang.Throwable e, java.lang.Object... msgParts)
              Send a trace message to the log.
    static void logWarning(java.lang.String context, java.lang.String message)
              Send a warning message to the log.
    static void logWarning(java.lang.String context, java.lang.Throwable e, java.lang.String message)
              Send a warning message to the log.
    static void setLogConfiguration(LogConfiguration config)
               
    static void setLogListener(LogListener listener)
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    LogManager

    public LogManager()
    Method Detail

    logCritical

    public static void logCritical(java.lang.String context,
                                   java.lang.String message)
    Send a critical message to the log. This level of message is generally used to record an event or error that must be recorded (if any logging is used). If it is used to record an error, it generally means that the system encountered a critical error which affects the integrity, accuracy, reliability and/or capability of the system.

    Only if the log manager is configured to send such messages to the destination will the message be recorded.

    Parameters:
    context - the context for this log message (for example, the component that is generating this message).
    message - the log message; the message is not logged if this parameter is null

    logCritical

    public static void logCritical(java.lang.String context,
                                   java.lang.Throwable e,
                                   java.lang.String message)
    Send a critical message to the log. This level of message is generally used to record an event or error that must be recorded (if any logging is used). If it is used to record an error, it generally means that the system encountered a critical error which affects the integrity, accuracy, reliability and/or capability of the system.

    Only if the log manager is configured to send such messages to the destination will the message be recorded.

    Parameters:
    context - the context for this log message (for example, the component that is generating this message).
    e - the exception that is to be logged; the message is not logged if this parameter is null
    message - the log message (may be null)

    logError

    public static void logError(java.lang.String context,
                                java.lang.String message)
    Send an error message to the log. Error messages are generally used to record unexpected problems, or errors that are not critical in nature and from which the system can automatically recover.

    Only if the log manager is configured to send such messages to the destination will the message be recorded.

    Parameters:
    context - the context for this log message (for example, the component that is generating this message).
    message - the log message; the message is not logged if this parameter is null

    logError

    public static void logError(java.lang.String context,
                                java.lang.Throwable e,
                                java.lang.String message)
    Send an error message to the log. Error messages are generally used to record unexpected problems, or errors that are not critical in nature and from which the system can automatically recover.

    Only if the log manager is configured to send such messages to the destination will the message be recorded.

    Parameters:
    context - the context for this log message (for example, the component that is generating this message).
    e - the exception that is to be logged; the message is not logged if this parameter is null
    message - the log message (may be null)

    logWarning

    public static void logWarning(java.lang.String context,
                                  java.lang.String message)
    Send a warning message to the log. Warning messages generally described expected errors from which the system should recover. However, this level is used to record the fact that such an error or event did occur.

    Only if the log manager is configured to send such messages to the destination will the message be recorded.

    Parameters:
    context - the context for this log message (for example, the component that is generating this message).
    message - the log message; the message is not logged if this parameter is null

    logWarning

    public static void logWarning(java.lang.String context,
                                  java.lang.Throwable e,
                                  java.lang.String message)
    Send a warning message to the log. Warning messages generally described expected errors from which the system should recover. However, this level is used to record the fact that such an error or event did occur.

    Only if the log manager is configured to send such messages to the destination will the message be recorded.

    Parameters:
    context - the context for this log message (for example, the component that is generating this message).
    e - the exception that is to be logged; the message is not logged if this parameter is null
    message - the log message (may be null)

    logInfo

    public static void logInfo(java.lang.String context,
                               java.lang.String message)
    Send a information message to the log. This level of logging is the usually the normal level. All interesting periodic events should be logged at this level so someone looking through the log can see the amount and kind of processing happening in the system.

    Only if the log manager is configured to send such messages to the destination will the message be recorded.

    Parameters:
    context - the context for this log message (for example, the component that is generating this message).
    message - the log message; the message is not logged if this parameter is null

    logDetail

    public static void logDetail(java.lang.String context,
                                 java.lang.Object... msgParts)
    Send a detail message to the log. Such messages are moderately detailed, and help to debug typical problems in the system. Generally, these messages are not so detailed that the big picture gets lost.

    Only if the log manager is configured to send such messages to the destination will the message be recorded.

    Parameters:
    context - the context for this log message (for example, the component that is generating this message).
    msgParts - the individual parts of the log message; the message is not logged if this parameter is null

    logDetail

    public static void logDetail(java.lang.String context,
                                 java.lang.Throwable e,
                                 java.lang.String message)
    Send a detail message to the log. Such messages are moderately detailed, and help to debug typical problems in the system. Generally, these messages are not so detailed that the big picture gets lost.

    Only if the log manager is configured to send such messages to the destination will the message be recorded.

    Parameters:
    context - the context for this log message (for example, the component that is generating this message).
    e - the exception that is to be logged; the message is not logged if this parameter is null
    message - the log message (may be null)

    logTrace

    public static void logTrace(java.lang.String context,
                                java.lang.Object... msgParts)
    Send a trace message to the log. A trace message is the most detailed logging level, used to trace system execution for really nasty problems. At this level, logging will be so verbose that the system performance may be affected.

    Only if the log manager is configured to send such messages to the destination will the message be recorded.

    Parameters:
    context - the context for this log message (for example, the component that is generating this message).
    msgParts - the individual parts of the log message; the message is not logged if this parameter is null

    logTrace

    public static void logTrace(java.lang.String context,
                                java.lang.Throwable e,
                                java.lang.Object... msgParts)
    Send a trace message to the log. A trace message is the most detailed logging level, used to trace system execution for really nasty problems. At this level, logging will be so verbose that the system performance may be affected.

    Only if the log manager is configured to send such messages to the destination will the message be recorded.

    Parameters:
    context - the context for this log message (for example, the component that is generating this message).
    e - the exception that is to be logged; the message is not logged if this parameter is null
    msgParts - the individual parts of the log message (may be null)

    log

    public static void log(int msgLevel,
                           java.lang.String context,
                           java.lang.String message)
    Send a message of the specified level to the log.

    Only if the log manager is configured to send such messages to the destination will the message be recorded.

    Parameters:
    msgLevel -
    context - the context for this log message (for example, the component that is generating this message).
    message - the individual parts of the log message; the message is not logged if this parameter is null

    log

    public static void log(int msgLevel,
                           java.lang.String context,
                           java.lang.Throwable e,
                           java.lang.String message)
    Send a message of the specified level to the log.

    Only if the log manager is configured to send such messages to the destination will the message be recorded.

    Parameters:
    context - the context for this log message (for example, the component that is generating this message).
    e - the exception that is to be logged; the message is not logged if this parameter is null
    message - the individual parts of the log message; the message is not logged if this parameter is null

    getLogConfigurationCopy

    public static LogConfiguration getLogConfigurationCopy()
    Utility method to obtain the a modifiable log configuration for the LogManager.

    After modifying the log config, user must call setLogConfiguration(LogConfiguration) to affect the logging configuration.

    Returns:
    a modifiable copy of the current log configuration

    setLogConfiguration

    public static void setLogConfiguration(LogConfiguration config)

    setLogListener

    public static void setLogListener(LogListener listener)

    isMessageToBeRecorded

    public static boolean isMessageToBeRecorded(java.lang.String context,
                                                int msgLevel)
    Utility method to identify whether a log message with the specified context and level will be recorded in the LogManager's destinations.

    Parameters:
    context -
    msgLevel -
    Returns:
    true if the message would be recorded if sent to the LogManager, or false if it would be discarded by the LogManager.

    createLoggingProxy

    public static java.lang.Object createLoggingProxy(java.lang.String loggingContext,
                                                      java.lang.Object instance,
                                                      java.lang.Class[] interfaces,
                                                      int level)


    Copyright © 2009. All Rights Reserved.