com.sap.tc.loggingStandard
Class Logger

java.lang.Object
  |
  +--com.sap.tc.loggingStandard.Logger

public class Logger
extends java.lang.Object

This class is similar to java.util.logging.Logger, that contains a subset of method calls that are mainly for writing log messages.

All the methods that supports the output of a log messages are available, including the check for resource bundle for translation, and the additional check if message is loggable or not.
Other configuration, such as assigning handler, filter is not mapped. And concept of global handlers is not supported in the API, but is made possible through the configuration file.

Note that the output API is based on the JDK1.4 beta 2 version.


Method Summary
 void config(java.lang.String msg)
          Log a CONFIG message.
 void entering(java.lang.String sourceClass, java.lang.String sourceMethod)
          Log a method entry.
 void entering(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object param1)
          Log a method entry, with one parameter This is a convenience method that can be used to log entry to a method.
 void entering(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object[] params)
          Log a method entry, with an array of parameters.
 void exiting(java.lang.String sourceClass, java.lang.String sourceMethod)
          Log a method return.
 void exiting(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Object result)
          Log a method return, with result object.
 void fine(java.lang.String msg)
          Log a FINE message.
 void finer(java.lang.String msg)
          Log a FINER message.
 void finest(java.lang.String msg)
          Log a FINEST message.
 Level getLevel()
          Get the log level specifying which messages will be logged by this logger.
static Logger getLogger(java.lang.String name)
          Find or create a logger for a named subsystem.
static Logger getLogger(java.lang.String name, java.lang.String resourceBundleName)
          Find or create a logger for a named subsystem.
 java.lang.String getName()
          Get the name for this logger.
 java.util.ResourceBundle getResourceBundle()
          Retrieve the localization resource bundle for this logger.
 java.lang.String getResourceBundleName()
          Retrieve the localization resource bundle name for this logger.
 void info(java.lang.String msg)
          Log a INFO message.
 boolean isLoggable(Level level)
          Check if a message of the given level would actually be logged by this logger, in terms of level comparison.
 void log(Level level, java.lang.String msg)
          Log a message, with no arguments.
 void log(Level level, java.lang.String msg, java.lang.Object param1)
          Log a message, with no arguments.
 void log(Level level, java.lang.String msg, java.lang.Object[] params)
          Log a message, with an array of object arguments.
 void log(Level level, java.lang.String msg, java.lang.Throwable thrown)
          Log a message, with associated Throwable information.
 void logp(Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Log a message, specifying source class and method, with no arguments.
 void logp(Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object param1)
          Log a message, specifying source class and method, with a single object parameter to the log message.
 void logp(Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Object[] params)
          Log a message, specifying source class and method, with an array of object arguments If the logger is currently enabled for the given message level then the given message is forwarded to all the registered output Handler objects.
 void logp(Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg, java.lang.Throwable thrown)
          Log a message, specifying source class and method, with associated Throwable information.
 void logrb(Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg)
          Log a message, specifying source class, method, and resource bundle name with no arguments.
 void logrb(Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg, java.lang.Object param1)
          Log a message, specifying source class, method, and resource bundle name with a single object parameter to the log message.
 void logrb(Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg, java.lang.Object[] params)
          Log a message, specifying source class, method, and resource bundle name with an array of object arguments.
 void logrb(Level level, java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String bundleName, java.lang.String msg, java.lang.Throwable thrown)
          Log a message, specifying source class, method, and resource bundle name with associated Throwable information.
 void setLevel(Level newLevel)
          Set the log level specifying which message levels will be logged by this logger (not affecting children).
 void severe(java.lang.String msg)
          Log a SEVERE message.
 void throwing(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.Throwable thrown)
          Log throwing an exception.
 void warning(java.lang.String msg)
          Log a WARNING message.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLogger

public static Logger getLogger(java.lang.String name)
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.

If a new logger is created its log level will be configured based on the LogManager info. It will be registered in the LogManager global namespace. This will mean it will be affected by subsequent LogManager.setLevel calls.

Parameters:
name - 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 java.net or javax.swing. No empty Logger name allowed, as root is always there.
Returns:
a suitable Logger

getLogger

public static Logger getLogger(java.lang.String name,
                               java.lang.String resourceBundleName)
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.

If a new logger is created its log level will be configured based on the LogManager. It will be registered in the LogManager global namespace. This will mean it will be affected by subsequent LogManager.setLevel calls.

If the named Logger already exists and does not yet have a localization resource bundle then the given resource bundle name is used. If the named Logger already exists and has a different resource bundle name then an IllegalArgumentException is thrown.

Parameters:
name - 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 java.net or javax.swing.No empty string allowed, as root is always there.
resourceBundleName - name of ResourceBundle to be used for localizing messages for this logger.
Returns:
a suitable Logger
Throws:
java.util.MissingResourceException - if the named ResourceBundle cannot be found.
IllegalArgumentName - if the Logger already exists and uses a different resource bundle name.

setLevel

public void setLevel(Level newLevel)
              throws java.lang.SecurityException
Set the log level specifying which message levels will be logged by this logger (not affecting children). Message levels lower than this value will be discarded. The level value Level.OFF can be used to turn off logging.
Parameters:
newLevel - the new value for the log level
Throws:
java.lang.SecurityException - if a security manager exists and if the caller does not have LoggingPermission("control").

getLevel

public Level getLevel()
Get the log level specifying which messages will be logged by this logger.
Returns:
the level of messages being logged.

getName

public java.lang.String getName()
Get the name for this logger.
Returns:
logger name.

getResourceBundleName

public java.lang.String getResourceBundleName()
Retrieve the localization resource bundle name for this logger.
Returns:
localization bundle name (may be null)

getResourceBundle

public java.util.ResourceBundle getResourceBundle()
Retrieve the localization resource bundle for this logger.
Returns:
localization bundle (may be null)

isLoggable

public boolean isLoggable(Level level)
Check if a message of the given level would actually be logged by this logger, in terms of level comparison.
Parameters:
level - a message logging level
Returns:
true if the given message level is currently being logged.

config

public void config(java.lang.String msg)
Log a CONFIG message.

If the logger is currently enabled for the CONFIG message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
msg - The string message (or a key in the message catalog)

fine

public void fine(java.lang.String msg)
Log a FINE message.

If the logger is currently enabled for the FINE message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
msg - The string message (or a key in the message catalog)

finer

public void finer(java.lang.String msg)
Log a FINER message.

If the logger is currently enabled for the FINER message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
msg - The string message (or a key in the message catalog)

finest

public void finest(java.lang.String msg)
Log a FINEST message.

If the logger is currently enabled for the FINEST message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
msg - The string message (or a key in the message catalog)

info

public void info(java.lang.String msg)
Log a INFO message.

If the logger is currently enabled for the INFO message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
msg - The string message (or a key in the message catalog)

severe

public void severe(java.lang.String msg)
Log a SEVERE message.

If the logger is currently enabled for the SEVERE message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
msg - The string message (or a key in the message catalog)

warning

public void warning(java.lang.String msg)
Log a WARNING message.

If the logger is currently enabled for the WARNING message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
msg - The string message (or a key in the message catalog)

log

public void log(Level level,
                java.lang.String msg)
Log a message, with no arguments.

If the logger is currently enabled for the given message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
level - One of the message level identifiers, e.g. SEVERE
msg - The string message (or a key in the message catalog)

log

public void log(Level level,
                java.lang.String msg,
                java.lang.Object param1)
Log a message, with no arguments.

If the logger is currently enabled for the given message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
level - One of the message level identifiers, e.g. SEVERE
msg - The string message (or a key in the message catalog)
param1 - parameter to the message

log

public void log(Level level,
                java.lang.String msg,
                java.lang.Object[] params)
Log a message, with an array of object arguments.

If the logger is currently enabled for the given message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
level - One of the message level identifiers, e.g. SEVERE
msg - The string message (or a key in the message catalog)
params - array of parameters to the message

log

public void log(Level level,
                java.lang.String msg,
                java.lang.Throwable thrown)
Log a message, with associated Throwable information.

If the logger is currently enabled for the given message level then the given message is forwarded to all the registered output Handler objects. Note (SAP wrapper): that the thrown argument is stored in the LogRecord parameters property.

Parameters:
level - One of the message level identifiers, e.g. SEVERE
msg - The string message (or a key in the message catalog)
params - array of parameters to the message

logp

public void logp(Level level,
                 java.lang.String sourceClass,
                 java.lang.String sourceMethod,
                 java.lang.String msg)
Log a message, specifying source class and method, with no arguments.

If the logger is currently enabled for the given message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
level - One of the message level identifiers, e.g. SEVERE
sourceClass - name of class that issued the logging request
sourceMethod - name of method that issued the logging request
msg - The string message (or a key in the message catalog)

logp

public void logp(Level level,
                 java.lang.String sourceClass,
                 java.lang.String sourceMethod,
                 java.lang.String msg,
                 java.lang.Object param1)
Log a message, specifying source class and method, with a single object parameter to the log message.

If the logger is currently enabled for the given message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
level - One of the message level identifiers, e.g. SEVERE
sourceClass - name of class that issued the logging request
sourceMethod - name of method that issued the logging request
msg - The string message (or a key in the message catalog)
param1 - Parameter to the log message

logp

public void logp(Level level,
                 java.lang.String sourceClass,
                 java.lang.String sourceMethod,
                 java.lang.String msg,
                 java.lang.Object[] params)
Log a message, specifying source class and method, with an array of object arguments

If the logger is currently enabled for the given message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
level - One of the message level identifiers, e.g. SEVERE
sourceClass - name of class that issued the logging request
sourceMethod - name of method that issued the logging request
msg - The string message (or a key in the message catalog)
params - Array of parameters to the message

logp

public void logp(Level level,
                 java.lang.String sourceClass,
                 java.lang.String sourceMethod,
                 java.lang.String msg,
                 java.lang.Throwable thrown)
Log a message, specifying source class and method, with associated Throwable information.

If the logger is currently enabled for the given message level then the given message is forwarded to all the registered output Handler objects.

Note (SAP wrapper): that the thrown argument is stored in the LogRecord parameters property.

Parameters:
level - One of the message level identifiers, e.g. SEVERE
sourceClass - name of class that issued the logging request
sourceMethod - name of method that issued the logging request
msg - The string message (or a key in the message catalog)
thrown - Throwable associated with log message.

logrb

public void logrb(Level level,
                  java.lang.String sourceClass,
                  java.lang.String sourceMethod,
                  java.lang.String bundleName,
                  java.lang.String msg)
Log a message, specifying source class, method, and resource bundle name with no arguments.

If the logger is currently enabled for the given message level then the given message is forwarded to all the registered output Handler objects.

The msg string is localized using the named resource bundle. If the resource bundle name is null, then the msg string is not localized.

Parameters:
level - One of the message level identifiers, e.g. SEVERE
sourceClass - name of class that issued the logging request
sourceMethod - name of method that issued the logging request
bundleName - name of resource bundle to localize msg
msg - The string message (or a key in the message catalog)
Throws:
java.util.MissingResourceException - if no suitable ResourceBundle can be found.

logrb

public void logrb(Level level,
                  java.lang.String sourceClass,
                  java.lang.String sourceMethod,
                  java.lang.String bundleName,
                  java.lang.String msg,
                  java.lang.Object param1)
Log a message, specifying source class, method, and resource bundle name with a single object parameter to the log message.

If the logger is currently enabled for the given message level then the given message is forwarded to all the registered output Handler objects.

The msg string is localized using the named resource bundle. If the resource bundle name is null, then the msg string is not localized.

Parameters:
level - One of the message level identifiers, e.g. SEVERE
sourceClass - name of class that issued the logging request
sourceMethod - name of method that issued the logging request
bundleName - name of resource bundle to localize msg
msg - The string message (or a key in the message catalog)
param1 - Parameter to the log message
Throws:
java.util.MissingResourceException - if no suitable ResourceBundle can be found.

logrb

public void logrb(Level level,
                  java.lang.String sourceClass,
                  java.lang.String sourceMethod,
                  java.lang.String bundleName,
                  java.lang.String msg,
                  java.lang.Object[] params)
Log a message, specifying source class, method, and resource bundle name with an array of object arguments.

If the logger is currently enabled for the given message level then the given message is forwarded to all the registered output Handler objects.

The msg string is localized using the named resource bundle. If the resource bundle name is null, then the msg string is not localized.

Parameters:
level - One of the message level identifiers, e.g. SEVERE
sourceClass - name of class that issued the logging request
sourceMethod - name of method that issued the logging request
bundleName - name of resource bundle to localize msg
msg - The string message (or a key in the message catalog)
params - Array of parameters to the message
Throws:
java.util.MissingResourceException - if no suitable ResourceBundle can be found.

logrb

public void logrb(Level level,
                  java.lang.String sourceClass,
                  java.lang.String sourceMethod,
                  java.lang.String bundleName,
                  java.lang.String msg,
                  java.lang.Throwable thrown)
Log a message, specifying source class, method, and resource bundle name with associated Throwable information.

If the logger is currently enabled for the given message level then the given message is forwarded to all the registered output Handler objects.

The msg string is localized using the named resource bundle. If the resource bundle name is null, then the msg string is not localized.

Note (SAP wrapper): that the thrown argument is stored in the LogRecord parameters property

Parameters:
level - One of the message level identifiers, e.g. SEVERE
sourceClass - name of class that issued the logging request
sourceMethod - name of method that issued the logging request
bundleName - name of resource bundle to localize msg
msg - The string message (or a key in the message catalog)
thrown - Throwable associated with log message.
Throws:
java.util.MissingResourceException - if no suitable ResourceBundle can be found.

entering

public void entering(java.lang.String sourceClass,
                     java.lang.String sourceMethod)
Log a method entry.

This is a convenience method that can be used to log entry to a method. A LogRecord with message "ENTRY", log level FINER, and the given sourceMethod and sourceClass is logged.

Parameters:
sourceClass - name of class that issued the logging request
sourceMethod - name of method that is being entered

entering

public void entering(java.lang.String sourceClass,
                     java.lang.String sourceMethod,
                     java.lang.Object param1)
Log a method entry, with one parameter

This is a convenience method that can be used to log entry to a method. A LogRecord with message "ENTRY with {0}", log level FINER, and the given sourceMethod and sourceClass and parameter is logged.

Parameters:
sourceClass - name of class that issued the logging request
sourceMethod - name of method that is being entered
param1 - parameter to the method being entered

entering

public void entering(java.lang.String sourceClass,
                     java.lang.String sourceMethod,
                     java.lang.Object[] params)
Log a method entry, with an array of parameters.

This is a convenience method that can be used to log entry to a method. A LogRecord with message "ENTRY", (followed by a format {N} indicator for each entry in the parameter array), log level FINER, and the given sourceMethod and sourceClass, and parameters is logged.

Parameters:
sourceClass - name of class that issued the logging request
sourceMethod - name of method that is being entered
params - array of parameters to the method being entered

exiting

public void exiting(java.lang.String sourceClass,
                    java.lang.String sourceMethod)
Log a method return.

This is a convenience method that can be used to log returning from a method. A LogRecord with message "RETURN", log level FINER, and the given sourceMethod and sourceClass is logged.

Parameters:
sourceClass - name of class that issued the logging request
sourceMethod - name of the method

exiting

public void exiting(java.lang.String sourceClass,
                    java.lang.String sourceMethod,
                    java.lang.Object result)
Log a method return, with result object.

This is a convenience method that can be used to log returning from a method. A LogRecord with message "RETURN with {0}", log level FINER, and the given sourceMethod and sourceClass, and result object is logged.

Parameters:
sourceClass - name of class that issued the logging request
sourceMethod - name of the method
result - Object that is being returned

throwing

public void throwing(java.lang.String sourceClass,
                     java.lang.String sourceMethod,
                     java.lang.Throwable thrown)
Log throwing an exception.

This is a convenience method to log that a method is terminating by throwing an exception. The logging is done using the FINER level.

If the logger is currently enabled for the given message level then it is forwarded to all registered output destinations. The LogRecord's message is set to "THROWING {0}".

Note that the thrown argument is stored in the LogRecord parameters property.

Parameters:
sourceClass - name of class that issued the logging request
sourceMethod - name of the method.
thrown - The Throwable that is being thrown.