com.ibm.mashups.enabler.logging
Interface Logger


public Logger

A Logger object is used to log messages for a specific system or application component. Loggers are normally named, using a hierarchical dot-separated namespace. Logger names can be arbitrary strings, but they should normally be based on the package name or class name of the logged component, such as com.ibm.mm.enabler or com.ibm.mm.enabler.services.ConfigService.

Logger objects may be obtained by calls on one of the getLogger factory methods. These will either create a new Logger or return a suitable existing Logger.

Logging messages will be forwarded to registered Handler objects, which can forward the messages to a variety of destinations, including consoles, files, OS logs, etc.

Each Logger keeps track of a "parent" Logger, which is its nearest existing ancestor in the Logger namespace. The default Enabler logging framework uses only one parent logger, the "root Logger"

On each logging call the Logger initially performs a cheap check of the request level (e.g. SEVERE or TRACE) against the effective global log level for the logger. If the request level is lower than the log level, the logging call returns immediately.

After passing this initial (cheap) test, the Logger will publish a the specified paramters to its output Handlers. By default, if the logger is not the root logger, it also publishes to it's parent's Handlers.

Most of the logger output methods take a "message" argument. This message argument may be either a raw value or a format string. During formatting, the format string will be filled in with the specified parameters. Otherwise the original message string is used. Typically the logger uses dojo.string.substitute style formatting to format parameters, so for example a format string "$ { 0} $ { 1}" would format two parameters as strings.

A global JS object can be used to configure the loggers that are considered for tracing.
This object is named traceConfig and can be accessed through the  ConfigService or initialized by ConfigService.properties

[ "com.ibm.mashups.*",
"com.ibm.mm.*" ]

Additional to the classes that should be logged the isDebug Flag must be set to true.

Since:
2.0

Method Summary
 Logger getLogger(String loggerName)
           Find or create a logger for a named subsystem.
 void entering(String methodName, Object[] args)
           This is a convenience method that can be used to log entry to a method.
 void exiting(String methodName, Object[] args)
           This is a convenience method that can be used to log returning of a method.
 void info(String methodName, String message, Object[] args)
           This method allows components to log an INFO level event.
 void warning(String methodName, String message, Object[] args)
           This method allows components to log an WARNING level event.
 void severe(String methodName, String message, Object[] args)
           This method allows components to log an SEVERE level event.
 void trace(String methodName, String message, Object[] args)
           This method allows components to log an TRACE level event.
 void log(int logLevel, String methodName, String message, Object[] args)
           This method allows components to log a logging event for the specified  LogLevel
 boolean isLoggable(int logLevel)
           Check if a message of the given level would actually be logged by this logger.
 

Method Detail

getLogger

Logger getLogger(String loggerName)
Find or create a logger for a named subsystem. If a logger has already been created with the given name it is returned. Otherwise a new logger is created.

Parameters:
loggerName - A name for the logger. This should be a dot-separated name and should normally be based on the package name or class name of the subsystem, such as com.ibm.mm.enabler or com.ibm.mm.enabler.services.ConfigService
Returns:
a suitable Logger

entering

void entering(String methodName,
              Object[] args)
This is a convenience method that can be used to log entry to a method. A event with the message "ENTRY", log level TRACE, and the given methodName is published

Parameters:
methodName - the name of the method .
args - array of arguments that's passed into the method. Those arguments will be added to the entering comment in a comma separated way.

exiting

void exiting(String methodName,
             Object[] args)
This is a convenience method that can be used to log returning of a method. A event with the message "RETURN", log level TRACE, and the given methodName is published. This method allows components to trace the exiting of the method.

Parameters:
methodName - the name of the method .
args - array of arguments that's passed into the method. Those arguments will be added to the exiting comment in a comma separated way.

info

void info(String methodName,
          String message,
          Object[] args)
This method allows components to log an INFO level event.

Parameters:
methodName - the name of the method .
message - the message that you want to log.
args - array of arguments that's passed into the method. Those arguments will be filled into the wildcards in your message.

warning

void warning(String methodName,
             String message,
             Object[] args)
This method allows components to log an WARNING level event.

Parameters:
methodName - the name of the method .
message - the message that you want to log.
args - array of arguments that's passed into the method. Those arguments will be filled into the wildcards in your message.

severe

void severe(String methodName,
            String message,
            Object[] args)
This method allows components to log an SEVERE level event.

Parameters:
methodName - the name of the method .
message - the message that you want to log.
args - array of arguments that's passed into the method. Those arguments will be filled into the wildcards in your message.

trace

void trace(String methodName,
           String message,
           Object[] args)
This method allows components to log an TRACE level event.

Parameters:
methodName - the name of the method .
message - the message that you want to log.
args - array of arguments that's passed into the method. Those arguments will be filled into the wildcards in your message.

log

void log(int logLevel,
         String methodName,
         String message,
         Object[] args)
This method allows components to log a logging event for the specified  LogLevel

Parameters:
logLevel - the  LogLevel to use for logging.
methodName - the name of the method.
message - the message that you want to log.
args - array of arguments that's passed into the method. Those arguments will be filled into the wildcards in your message.

isLoggable

boolean isLoggable(int logLevel)
Check if a message of the given level would actually be logged by this logger.

Parameters:
logLevel - the  LogLevel to check
Returns:
true if the given message level is currently being logged.


Copyright IBM Corp. 2010 All Rights Reserved.