Oracle Fusion Middleware Java API Reference for Oracle Data Visualization Components
11g Release 1 (11.1.1)

E12063-04

oracle.dss.util.xdo.common.log
Class Logger

java.lang.Object
  extended by oracle.dss.util.xdo.common.log.Logger
All Implemented Interfaces:
XDOLogConstants

public class Logger
extends java.lang.Object
implements XDOLogConstants

This class is a central logging facility for xDocPro.

General usage

This class is designed as a static class so that you can use this class without creating an instance. Basically, all you have to do to log the message is to call a log() method. The example is following.
 
 // Log a message 
 Logger.log("Copying string from buffer xyz to buffer zyx.", Logger.STATEMENT);
 
 // Log a message with the current object
 Logger.log(this, "Copying string from buffer xyz to buffer zyx.", Logger.STATEMENT);
 
 // Log an exception 
 Logger.log(exception);
 
 // Log an exception with level. 
 Logger.log(exception, Logger.EXCEPTION);
 
 // Log an exception with level and the current object 
 Logger.log(this, exception, Logger.EXCEPTION);
 

Logging level

There are 7 logging levels following. Levels are shown in descending order of severity. The top one is the most severe. There are 2 logging levels used in this class. One is the system logging level, another one is the logging level for each log message. Only log messages which have a level greater than or equal to the system logging level will be logged. When you set the system logging level to 'OFF', no log info will be displayed. You can set the system logging level by calling setLevel() method. The default system logging level is EXCEPTION. You can set the logging level for each log message by passing the level parameter to each log() method.
 
 // Set the system logging level to EXCEPTION 
 Logger.setLevel(Logger.EXCEPTION);
 
 // This log message will not be logged because the message 
 // logging level is lower than EXCEPTION
 Logger.log(this, "Copying string from buffer xyz to buffer zyx.", Logger.STATEMENT);
 
 // This log message will be logged because the message 
 // logging level is the same or higher than EXCEPTION
 Logger.log(this, "Copying string from buffer xyz to buffer zyx.", Logger.EXCEPTION);
 
 

Logging target

The default logging target is System.out. But you can change that. Please refer each implementation of XDOLog interface how to change the destination.

See Also:
XDOLog

Field Summary
 
Fields inherited from interface oracle.dss.util.xdo.common.log.XDOLogConstants
ERROR, EVENT, EXCEPTION, OFF, PROCEDURE, RCS_ID, STATEMENT, UNEXPECTED
 
Method Summary
static XDOLog getLog()
          Returns the Log instance that is used in this class.
static java.lang.String getLogDir()
          Returns the in the debug configuration file.
static java.lang.String getTimeStampStr()
          Get the current time stamp
Example return value:
"012104_020341453" means 1/21/2004 02:03:41.453
static boolean hasExceptions()
           
static void init()
          This method will check the xdodebug.cfg file under the /lib directory and turn the debug mode on or off.
static boolean isDebugMode()
          Returns true if it's in the debug mode
static boolean isEnabled(int pLevel)
          Checks whether logging is enabled for this level.
static void log(java.lang.Object pObj, java.lang.String pMsg, int pLevel)
          Writes the given string to the log, passing in the object doing the calling.
static void log(java.lang.Object pObj, java.lang.Throwable pError)
          Writes the stack trace of given Throwable to the log with the EXCEPTION message logging level.
static void log(java.lang.Object pObj, java.lang.Throwable pError, int pLevel)
          Writes the stack trace of given Throwable to the log, passing in the object doing the calling.
static void log(java.lang.String pMsg)
          Deprecated.  
static void log(java.lang.String pMsg, int pLevel)
          Writes the given string to the log, passing in the object doing the calling.
static void log(java.lang.Throwable pError)
          Writes the stack trace of given Throwable to the log with the EXCEPTION message logging level.
static void log(java.lang.Throwable pError, int pLevel)
          Writes the stack trace of given Throwable to the log.
static java.io.InputStream logFile(java.io.InputStream in, java.lang.String filename)
          Logs a file under the specified by xdodebug.cfg.
static java.io.Reader logFile(java.io.Reader in, java.lang.String filename)
          Logs a file under the specified by xdodebug.cfg.
static void main(java.lang.String[] args)
           
static void setLevel(int pLevel)
          Sets the system logging level.
static void setLog(XDOLog pLog)
          Sets the Log instance that you want to use in this class.
static void setModule(java.lang.String pModule)
          Sets the class/package for which logging should be turned on.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setLog

public static void setLog(XDOLog pLog)
Sets the Log instance that you want to use in this class.

Parameters:
pLog - XDOLog instance.

getLog

public static XDOLog getLog()
Returns the Log instance that is used in this class.

Returns:
XDOLog instance.

setLevel

public static void setLevel(int pLevel)
Sets the system logging level. There are 7 logging levels following. Levels are shown in descending order of severity. The top one is the most severe. Only log messages which have a level greater than or equal to the system logging level will be logged. When you set the system logging level to 'OFF', no log info will be displayed. The default system logging level is EXCEPTION. You can set the logging level for each log message by passing the level parameter to each log() method. The sample code snippet is following.
 
 // Set the system logging level to EXCEPTION 
 Logger.setLevel(Logger.EXCEPTION);
 
 // This log message will not be logged because the message 
 // logging level is lower than EXCEPTION
 Logger.log(this, "Copying string from buffer xyz to buffer zyx.", Logger.STATEMENT);
 
 // This log message will be logged because the message 
 // logging level is the same or higher than EXCEPTION
 Logger.log(this, "Copying string from buffer xyz to buffer zyx.", Logger.EXCEPTION);
 
 

Parameters:
pLevel - System logging level

setModule

public static void setModule(java.lang.String pModule)
Sets the class/package for which logging should be turned on. If you pass If you pass "all", it will log everything. The default is "all".

Parameters:
pModule - Module name to be logged

log

public static void log(java.lang.Object pObj,
                       java.lang.String pMsg,
                       int pLevel)
Writes the given string to the log, passing in the object doing the calling. The string should be displayed only if the level passed is greater than or equal to the current system logging level.

Parameters:
pObj - the "this" pointer sent by the caller to determine which class is writing the log message
pString - the hard-coded string to write to the log
pLevel - the level of the message

log

public static void log(java.lang.String pMsg)
Deprecated. 


log

public static void log(java.lang.String pMsg,
                       int pLevel)
Writes the given string to the log, passing in the object doing the calling. The string should be displayed only if the level passed is greater than or equal to the current system logging level. It will ignore the module scope setting by setModule().

Parameters:
pString - the hard-coded string to write to the log
pLevel - the level of the message

log

public static void log(java.lang.Object pObj,
                       java.lang.Throwable pError,
                       int pLevel)
Writes the stack trace of given Throwable to the log, passing in the object doing the calling. The stack trace will be displayed only if the level passed is greater than or equal to the current system logging level.

Parameters:
pObj - the "this" pointer sent by the caller to determine which class is writing the log message
pError - java Error or Exception
pLevel - the level of the message

log

public static void log(java.lang.Throwable pError,
                       int pLevel)
Writes the stack trace of given Throwable to the log. The stack trace will be displayed only if the level passed is greater than or equal to the current system logging level. It will ignore the module scope setting by setModule().

Parameters:
pError - java Error or Exception
pLevel - the level of the message

log

public static void log(java.lang.Object pObj,
                       java.lang.Throwable pError)
Writes the stack trace of given Throwable to the log with the EXCEPTION message logging level. The stack trace will be displayed only if the system logging level is less than ERROR.

Parameters:
pLevel - the level of the message

log

public static void log(java.lang.Throwable pError)
Writes the stack trace of given Throwable to the log with the EXCEPTION message logging level. The stack trace will be displayed only if the system logging level is less than ERROR. It will ignore the module scope setting by setModule().

Parameters:
pObj - the "this" pointer sent by the caller to determine which class is writing the log message
pLevel - the level of the message

isEnabled

public static boolean isEnabled(int pLevel)
Checks whether logging is enabled for this level. For performance reasons, User must check this before constructing any new Objects for logging.

Parameters:
pLevel - the level of the message
Returns:
true if logging is enabled for pLevel false if logging is not.

hasExceptions

public static boolean hasExceptions()

getTimeStampStr

public static java.lang.String getTimeStampStr()
Get the current time stamp
Example return value:
"012104_020341453" means 1/21/2004 02:03:41.453


init

public static void init()
This method will check the xdodebug.cfg file under the /lib directory and turn the debug mode on or off. Each processor must call this method before calling any other Logger method.


isDebugMode

public static boolean isDebugMode()
Returns true if it's in the debug mode

Returns:

getLogDir

public static java.lang.String getLogDir()
Returns the in the debug configuration file. Returns null if the debug mode is off.

Returns:

logFile

public static java.io.InputStream logFile(java.io.InputStream in,
                                          java.lang.String filename)
Logs a file under the specified by xdodebug.cfg. If the debug mode is off, this method do nothing and returns the input InputStream as is. This method does not close the input InputSteam.

You must close the returned InputStream like:
in2 = logFile( in, filename );
...
// process ...
...
if( in2 != in )
{
in2.close();
}

Parameters:
in - InputStream to be logged
filename - filename for the log file
Returns:

logFile

public static java.io.Reader logFile(java.io.Reader in,
                                     java.lang.String filename)
Logs a file under the specified by xdodebug.cfg. If the debug mode is off, this method do nothing and returns the input InputStream as is. This method does not close the input Reader.

You must close the returned Reader like:
in2 = logFile( in, filename );
...
// process ...
...
if( in2 != in )
{
in2.close();
}

Parameters:
in - Reader to be logged
filename - filename for the log file
Returns:

main

public static void main(java.lang.String[] args)

Oracle Fusion Middleware Java API Reference for Oracle Data Visualization Components
11g Release 1 (11.1.1)

E12063-04

Copyright © 1997, 2010, Oracle. All rights reserved.