com.ibm.j2ca.extension.logging
Class LogUtils

java.lang.Object
  extended bycom.ibm.j2ca.extension.logging.LogUtils

public class LogUtils
extends java.lang.Object

LogUtils - Provides uniform access to the log/trace/monitoring/FFDC services. It needs a WBIResourceAdapter bean for initialization.

Author:
lefty@us.ibm.com

Constructor Summary
LogUtils(java.util.logging.Logger logger, java.lang.String packName, java.lang.String productName, java.lang.String productVersion)
          Constructs a LogUtils
LogUtils(WBIResourceAdapter ra)
          Constructs a LogUtils using the properties of the Resource Adapter.
LogUtils(WBIResourceAdapter ra, boolean isManaged)
          Constructs a LogUtils using the properties of the Resource Adapter
 
Method Summary
 void close()
          Remove the file handlers from the Logger and close the them.
 java.util.logging.Logger getLogger()
           
 boolean isLogEnabled(java.util.logging.Level logLevel)
          Checks if this log level is enabled
 boolean isTraceEnabled(java.util.logging.Level traceLevel)
          Checks if this trace level is enabled
 void log(java.util.logging.Level l, int bundleType, java.lang.String classname, java.lang.String method, java.lang.String msgKey)
          Generates a message and send it to the log destinations
 void log(java.util.logging.Level l, int bundleType, java.lang.String classname, java.lang.String method, java.lang.String msgKey, com.ibm.j2ca.extension.logging.cbe.CBEEngineData engine)
          Generates a message and send it to the log destinations
 void log(java.util.logging.Level l, int bundleType, java.lang.String classname, java.lang.String method, java.lang.String msgKey, java.lang.Object[] params)
          Generates a message and send it to the log destinations
 void log(java.util.logging.Level l, int bundleType, java.lang.String classname, java.lang.String method, java.lang.String msgKey, java.lang.Object[] params, com.ibm.j2ca.extension.logging.cbe.CBEEngineData engineData)
          Generates a message and send it to the log destinations
 void setLogger(java.util.logging.Logger logger)
           
 void setLoggingLevel(java.util.logging.Level level)
          Set the level in the logging logger.
 void setMonitoringLevel(java.util.logging.Level level)
          Set the level in the monitoring logger.
 void trace(java.util.logging.Level l, java.lang.String classname, java.lang.String method, java.lang.String msg)
          Generates a message and send it to the trace destinations
 void trace(java.util.logging.Level l, java.lang.String classname, java.lang.String method, java.lang.String msg, java.lang.Exception e)
          Generates a message and send it to the trace destinations
 void traceDataObject(commonj.sdo.DataObject busObj, java.lang.String classname, java.lang.String method)
          Dumps the data object contents using the AdaptarBOUtil's serializeDataObject method.
 void traceMethodEntrance(java.lang.String classname, java.lang.String methodSignature)
          Utility method to generate a trace message immediately after entering a method.
 void traceMethodExit(java.lang.String classname, java.lang.String methodSignature)
          Utility method to generate a trace message immediately before exiting a method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogUtils

public LogUtils(WBIResourceAdapter ra,
                boolean isManaged)
         throws javax.resource.spi.ResourceAdapterInternalException
Constructs a LogUtils using the properties of the Resource Adapter

Parameters:
ra - the ResourceAdapter for this LogUtils

LogUtils

public LogUtils(WBIResourceAdapter ra)
         throws javax.resource.spi.ResourceAdapterInternalException
Constructs a LogUtils using the properties of the Resource Adapter. Set the LogUtils to run on managed mode.

Parameters:
ra - the ResourceAdapter for this LogUtils

LogUtils

public LogUtils(java.util.logging.Logger logger,
                java.lang.String packName,
                java.lang.String productName,
                java.lang.String productVersion)
         throws javax.resource.spi.ResourceAdapterInternalException
Constructs a LogUtils

Parameters:
logger - the logger for this LogUtils
packName - the package name where to the LogMessages file
productName - the name of the product for this LogUtils
productVersion - the version of the product for this LogUtils
Method Detail

isTraceEnabled

public boolean isTraceEnabled(java.util.logging.Level traceLevel)
Checks if this trace level is enabled

Parameters:
traceLevel -
Returns:
true if it's enable false otherwise

isLogEnabled

public boolean isLogEnabled(java.util.logging.Level logLevel)
Checks if this log level is enabled

Parameters:
logLevel -
Returns:
true if it's enable false otherwise

trace

public void trace(java.util.logging.Level l,
                  java.lang.String classname,
                  java.lang.String method,
                  java.lang.String msg)
Generates a message and send it to the trace destinations

Parameters:
l - the level for the trace message
classname - the name of the class
method - the name of the method
msg - the message

trace

public void trace(java.util.logging.Level l,
                  java.lang.String classname,
                  java.lang.String method,
                  java.lang.String msg,
                  java.lang.Exception e)
Generates a message and send it to the trace destinations

Parameters:
l - the level for the trace message
classname - the name of the class
method - the name of the method
msg - the message
e - the exception to trace

traceDataObject

public void traceDataObject(commonj.sdo.DataObject busObj,
                            java.lang.String classname,
                            java.lang.String method)
Dumps the data object contents using the AdaptarBOUtil's serializeDataObject method.


log

public void log(java.util.logging.Level l,
                int bundleType,
                java.lang.String classname,
                java.lang.String method,
                java.lang.String msgKey,
                com.ibm.j2ca.extension.logging.cbe.CBEEngineData engine)
Generates a message and send it to the log destinations

Parameters:
l - the level for the log message
bundleType - the bundle type, valid values are LogUtilConstants.ADAPTER_RBUNDLE and LogUtilConstants.BASE_RBUNDLE
classname - the name of the class
method - the name of the method
msgKey - the key of the message in the ResourceBundle

log

public void log(java.util.logging.Level l,
                int bundleType,
                java.lang.String classname,
                java.lang.String method,
                java.lang.String msgKey)
Generates a message and send it to the log destinations

Parameters:
l - the level for the log message
bundleType - the bundle type, valid values are LogUtilConstants.ADAPTER_RBUNDLE and LogUtilConstants.BASE_RBUNDLE
classname - the name of the class
method - the name of the method
msgKey - the key of the message in the ResourceBundle

log

public void log(java.util.logging.Level l,
                int bundleType,
                java.lang.String classname,
                java.lang.String method,
                java.lang.String msgKey,
                java.lang.Object[] params,
                com.ibm.j2ca.extension.logging.cbe.CBEEngineData engineData)
Generates a message and send it to the log destinations

Parameters:
l - the level for the log message
bundleType - the bundle type, valid values are LogUtilConstants.ADAPTER_RBUNDLE and LogUtilConstants.BASE_RBUNDLE
classname - the name of the class
method - the name of the method
msgKey - the key of the message in the ResourceBundle
params - the parameters to format the message
engineData - store the event type data

log

public void log(java.util.logging.Level l,
                int bundleType,
                java.lang.String classname,
                java.lang.String method,
                java.lang.String msgKey,
                java.lang.Object[] params)
Generates a message and send it to the log destinations

Parameters:
l - the level for the log message
bundleType - the bundle type, valid values are LogUtilConstants.ADAPTER_RBUNDLE and LogUtilConstants.BASE_RBUNDLE
classname - the name of the class
method - the name of the method
msgKey - the key of the message in the ResourceBundle
params - the parameters to format the message

setLoggingLevel

public void setLoggingLevel(java.util.logging.Level level)
Set the level in the logging logger. This method will only change the level if the resource adapter is running in unmanaged mode.

Parameters:
level - the new level

setMonitoringLevel

public void setMonitoringLevel(java.util.logging.Level level)
Set the level in the monitoring logger. This method will only change the level if the resource adapter is running in unmanaged mode. This level is to set how much information must be sent to the log files. FINEST - is a dump bo FINER - output only the keys FINE and above - output only the bo name

Parameters:
level - the new level

close

public void close()
Remove the file handlers from the Logger and close the them.


traceMethodEntrance

public void traceMethodEntrance(java.lang.String classname,
                                java.lang.String methodSignature)
Utility method to generate a trace message immediately after entering a method.

Parameters:
classname - parent class of method
methodSignature - method name and optionally parameter types to uniquely identify the method. For example, "doSomething" or "doSomething(String,int)" if method doSomething is overloaded.

traceMethodExit

public void traceMethodExit(java.lang.String classname,
                            java.lang.String methodSignature)
Utility method to generate a trace message immediately before exiting a method.

Parameters:
classname - parent class of method
methodSignature - method name and optionally parameter types to uniquely identify the method. For example, "doSomething" or "doSomething(String,int)" if method doSomething is overloaded.

getLogger

public java.util.logging.Logger getLogger()

setLogger

public void setLogger(java.util.logging.Logger logger)