com.ibm.etools.logging.util
Class DefaultMsgLogger

java.lang.Object
  |
  +--com.ibm.etools.logging.util.DefaultMsgLogger

public final class DefaultMsgLogger
extends java.lang.Object

Licensed Material - Property of IBM (C) Copyright IBM Corp. 2003, 2005 - All Rights Reserved. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. This class is a wrapper of an instance of MsgLogger, where each of the static methods are delegated to this instance. CHANGE HISTORY Date Programmer Defect Description -------- ----------------- ------ -------------------------------- 23/01/01 rduggan@ca.ibm.com initial creation 14/09/01 paules@ca.ibm.com f184021 Added isLoggingLevel(Level), isLogging(), write([object/exception/primitive/thread]), writeCurrentThread(), setLevel(Level), getLevel(), getXMLFormat(), setXMLFormat(boolean), removed printStackToString(Throwable), setActive(boolean) and related instance variable(s) 18/09/01 paules@ca.ibm.com 184264 Re-added deprecated methods printStackToString(Throwable) and setActive(boolean). 27/09/01 paules@ca.ibm.com 185401 Added write(Level,[object/exception/primitive/thread]) methods. 28/09/01 paules@ca.ibm.com 185404 Added isActive() and setActive() which turns 'on' (logging) or 'off' (idle) the logger. 16/01/02 paules@ca.ibm.com 193621 Added get/setXMLDepth() methods. 10/10/02 paules@ca.ibm.com 223820 Added waitUntilMonitored() API. 06/02/03 amehrega@ca.ibm.com 230886 APIs to force and turn on/off log file archiving.


Field Summary
protected static MsgLoggerFactory _factory
           
 
Constructor Summary
DefaultMsgLogger()
           
 
Method Summary
static void archiveFile()
          Archives the current file
static void closeFile()
          If the DefaultMsgLogger has an associated file handle to an output file for logging, the existing file handle is closed.
static void delArchivedFiles()
          Deletes archived files based on the archive expiry day'
static boolean getArchiveOnOff()
          Returns true if archving is on; otherwise false is returned
static java.lang.String getFileName()
          Returns the logging file name.
static boolean getFormatXMLOutput()
           
static int getLevel()
          Retrieves the level of this logger.
static java.lang.String getName()
          Retrieves the name of this logger.
static boolean getRotationalLogging()
          Returns 'true' if rotational logging is turned ON, otherwise false is returned
static int getXMLDepth()
          Retrieves the current depth or nesting level of XML serialized objects (-n = maximum depth, 0 = no nesting , n = 'n' nesting levels).
static boolean getXMLFormat()
          Determines whether this logger is using XML as it's output format.
static boolean isActive()
          Checks if the logger is actively logging or turned 'on'.
static boolean isLogging()
          Checks if the current logging level is set to log information.
static boolean isLoggingLevel(int level)
          Checks if the current logging level is at the parameter check level or higher (i.e.
static boolean isMonitored()
          Checks if the logger is being monitored.
static java.lang.String printStackToString(java.lang.Throwable aThrowable)
          Deprecated. This method is not the correct way to return an exception's stack trace as a String. Logging messages are now logged using the write([object/exception/primitive/thread]) method.
static void setActive(boolean active)
          This method sets the flag that turns the logger 'on' for active logging or 'off' for no logging.
static void setArchiveExpiryDays(int _archiveExpiryDays)
          Sets the archive expiry day
static void setArchiveOnOff(boolean archiveOnOff)
          Turns on/off archiving
static void setFileName(java.lang.String logFile)
          This method sets the file name where messages are to be logged.
static void setFormatXMLOutput(boolean formatXMLOutput)
           
static void setLevel(int newLevel)
          Set the level of logging to one of the 8 levels (i.e.
static void setMaxSize(long size)
          Sets the maximum size of the log file used for rotational logging.
static void setXMLDepth(int newDepth)
          Set the current depth or nesting level of XML serialized objects (-n = maximum depth, 0 = no nesting , n = 'n' nesting levels).
static void setXMLDetailLevel(int xmlDetailLevel)
           
static void setXMLFormat(boolean flag)
          Turns logging in XML format either on or off.
static void turnRLOff()
          Turns OFF rotational logging.
static boolean waitUntilMonitored(long maxTime)
          Suspends the current thread until the logging agent is monitored or the the parameter maximum time (milliseconds) has expired.
static void write(boolean msg)
          Log a boolean message.
static void write(byte msg)
          Log a bute message.
static void write(char msg)
          Log a char message.
static void write(double msg)
          Log a double message.
static void write(float msg)
          Log a float message.
static void write(int msg)
          Log an int message.
static void write(int level, boolean msg)
          Log a boolean message if the current logging level is at the parameter check level or higher (i.e.
static void write(int level, byte msg)
          Log a byte message if the current logging level is at the parameter check level or higher (i.e.
static void write(int level, char msg)
          Log a char message if the current logging level is at the parameter check level or higher (i.e.
static void write(int level, double msg)
          Log a double message if the current logging level is at the parameter check level or higher (i.e.
static void write(int level, float msg)
          Log a float message if the current logging level is at the parameter check level or higher (i.e.
static void write(int level, int msg)
          Log an int message if the current logging level is at the parameter check level or higher (i.e.
static void write(int level, long msg)
          Log a long message if the current logging level is at the parameter check level or higher (i.e.
static void write(int level, java.lang.Object obj)
          Log an Object message if the current logging level is at the parameter check level or higher (i.e.
static void write(int level, short msg)
          Log a short message if the current logging level is at the parameter check level or higher (i.e.
static void write(long msg)
          Log a long message.
static void write(java.lang.Object record)
          Log an Object message.
static void write(short msg)
          Log a short message.
static void writeCurrentThread()
          Log the stack trace of the current thread.
static void writeStackTrace()
          Log the current stack trace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_factory

protected static MsgLoggerFactory _factory
Constructor Detail

DefaultMsgLogger

public DefaultMsgLogger()
Method Detail

closeFile

public static void closeFile()
If the DefaultMsgLogger has an associated file handle to an output file for logging, the existing file handle is closed.


printStackToString

public static java.lang.String printStackToString(java.lang.Throwable aThrowable)
Deprecated. This method is not the correct way to return an exception's stack trace as a String. Logging messages are now logged using the write([object/exception/primitive/thread]) method.


setXMLDetailLevel

public static void setXMLDetailLevel(int xmlDetailLevel)
                              throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException

getFormatXMLOutput

public static boolean getFormatXMLOutput()

setFormatXMLOutput

public static void setFormatXMLOutput(boolean formatXMLOutput)

isActive

public static boolean isActive()
Checks if the logger is actively logging or turned 'on'.

Returns:
true if the logger is actively logging or turned 'on'

isMonitored

public static boolean isMonitored()
Checks if the logger is being monitored.

Returns:
true if the logger is being monitored

waitUntilMonitored

public static boolean waitUntilMonitored(long maxTime)
Suspends the current thread until the logging agent is monitored or the the parameter maximum time (milliseconds) has expired.

Parameters:
maxTime - the maximum amount of time (milliseconds) to suspend the current thread
Returns:
true if the logger is being monitored

setActive

public static void setActive(boolean active)
This method sets the flag that turns the logger 'on' for active logging or 'off' for no logging. If the logger has an associated file name as the output file for logging, a file handle is created when the logger is turned 'on' and the existing file handle is closed when the logger is turned 'off'. All other logger preferences are maintained while the logger is turned 'off'.

Parameters:
active - boolean flag that turns the logger 'on' or 'off'

getName

public static java.lang.String getName()
Retrieves the name of this logger.

Returns:
java.lang.String - a copy of the agent name

setLevel

public static void setLevel(int newLevel)
Set the level of logging to one of the 8 levels (i.e. LEVEL.FINEST - Level.NONE).

Parameters:
newLevel - new level of logging (i.e. LEVEL.FINEST - Level.NONE)

setMaxSize

public static void setMaxSize(long size)
Sets the maximum size of the log file used for rotational logging. It also turns rotational logging ON.

Parameters:
size - - The maximum size of the log file in bytes

turnRLOff

public static void turnRLOff()
Turns OFF rotational logging. To turn ON rotational logging, 'setMaxSize' needs to be invoked.


getRotationalLogging

public static boolean getRotationalLogging()
Returns 'true' if rotational logging is turned ON, otherwise false is returned

Returns:
true if rotational logging is ON; otherwise false

getLevel

public static int getLevel()
Retrieves the level of this logger.

Returns:
level of logging (i.e. LEVEL.FINEST - Level.NONE)

setXMLDepth

public static void setXMLDepth(int newDepth)
Set the current depth or nesting level of XML serialized objects (-n = maximum depth, 0 = no nesting , n = 'n' nesting levels).

Parameters:
newDepth - new depth or nesting level of XML serialized objects

getXMLDepth

public static int getXMLDepth()
Retrieves the current depth or nesting level of XML serialized objects (-n = maximum depth, 0 = no nesting , n = 'n' nesting levels).

Returns:
current depth or nesting level of XML serialized objects

setFileName

public static void setFileName(java.lang.String logFile)
This method sets the file name where messages are to be logged. If stand-alone mode is active, this overrides logging to standard out, by pumping all logs to the specified file. If standalone behavior is not active, then the file name is simply set for later use when standalone mode is enabled. If null is passed as a parameter, this stops logging to a file (and closes it), and redirects logging to Standard out.

Parameters:
logFile - new file name

getFileName

public static java.lang.String getFileName()
Returns the logging file name.

Returns:
String logging file name

setXMLFormat

public static void setXMLFormat(boolean flag)
Turns logging in XML format either on or off. Default is true. If set to false, a simple toString is done on the object passed to write method


getXMLFormat

public static boolean getXMLFormat()
Determines whether this logger is using XML as it's output format.

Returns:
true if this logger is using XML as it's output format

isLogging

public static boolean isLogging()
Checks if the current logging level is set to log information.

Returns:
true if logging is turned on (i.e. LEVEL.FINEST - Level.CONFIG), otherwise false (i.e. Level.NONE).

isLoggingLevel

public static boolean isLoggingLevel(int level)
Checks if the current logging level is at the parameter check level or higher (i.e. logging more information).

Returns:
true if the current logging level is at the parameter check level or higher.

write

public static void write(int level,
                         boolean msg)
Log a boolean message if the current logging level is at the parameter check level or higher (i.e. logging more information).

Parameters:
msg - the message to be logged

write

public static void write(boolean msg)
Log a boolean message.

Parameters:
msg - the message to be logged

write

public static void write(int level,
                         char msg)
Log a char message if the current logging level is at the parameter check level or higher (i.e. logging more information).

Parameters:
msg - the message to be logged

write

public static void write(char msg)
Log a char message.

Parameters:
msg - the message to be logged

write

public static void write(int level,
                         byte msg)
Log a byte message if the current logging level is at the parameter check level or higher (i.e. logging more information).

Parameters:
msg - the message to be logged

write

public static void write(byte msg)
Log a bute message.

Parameters:
msg - the message to be logged

write

public static void write(int level,
                         short msg)
Log a short message if the current logging level is at the parameter check level or higher (i.e. logging more information).

Parameters:
msg - the message to be logged

write

public static void write(short msg)
Log a short message.

Parameters:
msg - the message to be logged

write

public static void write(int level,
                         int msg)
Log an int message if the current logging level is at the parameter check level or higher (i.e. logging more information).

Parameters:
msg - the message to be logged

write

public static void write(int msg)
Log an int message.

Parameters:
msg - the message to be logged

write

public static void write(int level,
                         long msg)
Log a long message if the current logging level is at the parameter check level or higher (i.e. logging more information).

Parameters:
msg - the message to be logged

write

public static void write(long msg)
Log a long message.

Parameters:
msg - the message to be logged

write

public static void write(int level,
                         float msg)
Log a float message if the current logging level is at the parameter check level or higher (i.e. logging more information).

Parameters:
msg - the message to be logged

write

public static void write(float msg)
Log a float message.

Parameters:
msg - the message to be logged

write

public static void write(int level,
                         double msg)
Log a double message if the current logging level is at the parameter check level or higher (i.e. logging more information).

Parameters:
msg - the message to be logged

write

public static void write(double msg)
Log a double message.

Parameters:
msg - the message to be logged

write

public static void write(int level,
                         java.lang.Object obj)
Log an Object message if the current logging level is at the parameter check level or higher (i.e. logging more information).


write

public static void write(java.lang.Object record)
Log an Object message.


writeCurrentThread

public static void writeCurrentThread()
Log the stack trace of the current thread.


writeStackTrace

public static void writeStackTrace()
Log the current stack trace


setArchiveOnOff

public static void setArchiveOnOff(boolean archiveOnOff)
Turns on/off archiving

Parameters:
archiveOnOff - is a flag that turns 'on' or 'off' archiving

getArchiveOnOff

public static boolean getArchiveOnOff()
Returns true if archving is on; otherwise false is returned

Returns:
True if archiving is on; otherwise false

archiveFile

public static void archiveFile()
Archives the current file


delArchivedFiles

public static void delArchivedFiles()
Deletes archived files based on the archive expiry day'


setArchiveExpiryDays

public static final void setArchiveExpiryDays(int _archiveExpiryDays)
Sets the archive expiry day

Parameters:
_archiveExpiryDays - is an integer used to set the expiry days for archived file