public class WASTrace
extends java.lang.Object
Wrapper for the WebSphere trace facility. It allows various types of trace records to be written to the WebSphere Application Server trace file. To use WASTrace, your classpath should contain this class and WebSphere's ras.jar.
Although this class can be used to write trace records, it cannot be used for specifying trace settings. Users should use the administrators console to set trace settings for particular components and to specify how the trace will be collected by the system. The default application server setting is that all trace is disabled.
No initialization of WASTrace is needed before you begin invoking the trace methods. However, each of these methods requires a logger name that must be unique within the Commerce product. Logger names can be dotted separated to ensure uniqueness (for example, ShoppingCart, payments.MPF, payments.PDP).
Under WebSphere Application Server, you must use the administrator's console to specify the trace setting as well as the output file for your trace records. The location for the trace file is specified on the trace settings page in both WebSphere Application Server and WebSphere Studio.
Calling applications should condition each trace call with the isTracing() method to ensure optimal performance when tracing is disabled:
if (isTracing(LOGGER_NAME)) WASTrace.debug(LOGGER_NAME,...);
There are three WebSphere trace settings:
event
entryExit
debug
Using the WebSphere Administrator's console you can enable or disable these settings for each Commerce trace logger. You can also choose combinations of these settings.
Calls to the debug()
methods will write to the trace
log only when the debug
trace setting is enabled
for the specified logger.
Calls to the entry
and exit
methods
will write to the trace log only when the entryExit
is enabled for the specified logger.
Calls to the event()
and exception
methods will write to the trace log when any trace
setting is enabled for the specified logger.
WASLog
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COPYRIGHT
IBM copyright notice field.
|
Constructor and Description |
---|
WASTrace() |
Modifier and Type | Method and Description |
---|---|
static void |
debug(java.lang.String loggerName,
java.lang.String className,
java.lang.String methodName,
java.lang.String text)
Writes a trace record containing the specified text if
debug tracing for
the specified logger is enabled. |
static void |
debug(java.lang.String loggerName,
java.lang.String className,
java.lang.String methodName,
java.lang.String text,
java.lang.Object parm)
Writes a trace record containing the specified text and parameters
if
debug tracing for the specified logger is
enabled. |
static void |
debug(java.lang.String loggerName,
java.lang.String className,
java.lang.String methodName,
java.lang.String text,
java.lang.Object[] parms)
Writes a trace record containing the specified text and parameters
if
debug tracing for the specified logger is
enabled. |
static void |
entry(java.lang.String loggerName,
java.lang.String className,
java.lang.String methodName)
Writes a trace method entry record if
entryExit
tracing for the specified logger is enabled. |
static void |
entry(java.lang.String loggerName,
java.lang.String className,
java.lang.String methodName,
java.lang.Object parm)
Writes a trace method entry record if
entryExit
tracing for the specified logger is enabled. |
static void |
entry(java.lang.String loggerName,
java.lang.String className,
java.lang.String methodName,
java.lang.Object[] parms)
Writes a trace method entry record if
entryExit
tracing for the specified logger is enabled. |
static void |
event(java.lang.String loggerName,
java.lang.String className,
java.lang.String methodName,
java.lang.String text)
Writes a trace record containing the specified text if
any tracing is enabled for the specified logger.
|
static void |
event(java.lang.String loggerName,
java.lang.String className,
java.lang.String methodName,
java.lang.String text,
java.lang.Object[] parms)
Writes a trace record containing the specified text and
parameters if any tracing is enabled for the specified
logger.
|
static void |
exception(java.lang.String loggerName,
java.lang.String className,
java.lang.String methodName,
java.lang.Throwable t)
Writes a trace record containing the specified exception
if any tracing is enabled for the specified logger.
|
static void |
exit(java.lang.String loggerName,
java.lang.String className,
java.lang.String methodName)
Writes a trace method exit record if
entryExit
tracing for the specified logger is enabled. |
static void |
exit(java.lang.String loggerName,
java.lang.String className,
java.lang.String methodName,
java.lang.Object retValue)
Writes a trace method exit record containing the specified
return value if
entryExit
tracing for the specified logger is enabled. |
static com.ibm.ras.RASTraceLogger |
getTraceLogger(int loggerIndex)
Gets the RAS trace logger object associated with the specified index value.
|
static com.ibm.ras.RASTraceLogger |
getTraceLogger(java.lang.String loggerName)
Gets the RAS trace logger object for the specified component
|
static com.ibm.ras.RASTraceLogger |
getTraceLogger(java.lang.String loggerName,
int loggerIndex)
Gets the RAS trace logger object for the specified component name.
|
static boolean |
isTracing(int loggerIndex)
Indicates whether the trace logger is currently
enabled to trace records.
|
static boolean |
isTracing(java.lang.String loggerName)
Indicates whether the trace logger is currently
enabled to trace records.
|
public static final java.lang.String COPYRIGHT
public static final boolean isTracing(java.lang.String loggerName)
if (isTracing(LOGGER_NAME)) WASTrace.debug(LOGGER_NAME,...);This will improve the performance of the system since the arguments of the
debug(...)
method will not be evaluated when tracing
is disabled.loggerName
- the unique name for the trace loggerpublic static final boolean isTracing(int loggerIndex)
if (isTracing(LOGGER_INDEX)) WASTrace.debug(LOGGER_NAME,...);This will improve the performance of the system since the arguments of the
debug(...)
method will not be evaluated when tracing
is disabled.loggerIndex
- the component that has previously been associated with a trace logger.public static void debug(java.lang.String loggerName, java.lang.String className, java.lang.String methodName, java.lang.String text)
debug
tracing for
the specified logger is enabled.loggerName
- the unique name for the trace loggerclassName
- the name of the calling classmethodName
- the name of the calling methodtext
- the text to be written to the trace recordpublic static void debug(java.lang.String loggerName, java.lang.String className, java.lang.String methodName, java.lang.String text, java.lang.Object parm)
debug
tracing for the specified logger is
enabled.loggerName
- the unique name for the trace loggerclassName
- the name of the calling classmethodName
- the name of the calling methodtext
- the text to be written to the trace recordparam
- the data to be written to the trace record.public static void debug(java.lang.String loggerName, java.lang.String className, java.lang.String methodName, java.lang.String text, java.lang.Object[] parms)
debug
tracing for the specified logger is
enabled.loggerName
- the unique name for the trace loggerclassName
- the name of the calling classmethodName
- the name of the calling methodtext
- the text to be written to the trace recordparams
- the data to be written to the trace record. Each object
in the array should respond appropriately to the toString() method.public static void entry(java.lang.String loggerName, java.lang.String className, java.lang.String methodName)
entryExit
tracing for the specified logger is enabled.loggerName
- the unique name for the trace loggerclassName
- the name of the calling classmethodName
- the name of the calling methodpublic static void entry(java.lang.String loggerName, java.lang.String className, java.lang.String methodName, java.lang.Object parm)
entryExit
tracing for the specified logger is enabled.loggerName
- the unique name for the trace loggerclassName
- the name of the calling classmethodName
- the name of the calling methodparm
- the data to be written to the trace recordpublic static void entry(java.lang.String loggerName, java.lang.String className, java.lang.String methodName, java.lang.Object[] parms)
entryExit
tracing for the specified logger is enabled.loggerName
- the unique name for the trace loggerclassName
- the name of the calling classmethodName
- the name of the calling methodparms
- the data to be written to the trace recordpublic static void exit(java.lang.String loggerName, java.lang.String className, java.lang.String methodName)
entryExit
tracing for the specified logger is enabled.loggerName
- the unique name for the trace loggerclassName
- the name of the calling classmethodName
- the name of the calling methodpublic static void exit(java.lang.String loggerName, java.lang.String className, java.lang.String methodName, java.lang.Object retValue)
entryExit
tracing for the specified logger is enabled.loggerName
- the unique name for the trace loggerclassName
- the name of the calling classmethodName
- the name of the calling methodretValue
- the value to be returned by the calling methodpublic static void event(java.lang.String loggerName, java.lang.String className, java.lang.String methodName, java.lang.String text)
loggerName
- the unique name for the trace loggerclassName
- the name of the calling classmethodName
- the name of the calling methodtext
- the text to be written to the trace recordpublic static void event(java.lang.String loggerName, java.lang.String className, java.lang.String methodName, java.lang.String text, java.lang.Object[] parms)
loggerName
- the unique name for the trace loggerclassName
- the name of the calling classmethodName
- the name of the calling methodtext
- the text to be written to the trace recordparams
- the data to be written to the trace record. Each object
in the array should respond appropriately to the toString() method.public static void exception(java.lang.String loggerName, java.lang.String className, java.lang.String methodName, java.lang.Throwable t)
loggerName
- the unique name for the trace loggerclassName
- the name of the calling classmethodName
- the name of the calling methodt
- the Throwable to report in the trace logpublic static final com.ibm.ras.RASTraceLogger getTraceLogger(java.lang.String loggerName)
loggerName
- the component that identifies the trace loggerpublic static final com.ibm.ras.RASTraceLogger getTraceLogger(java.lang.String loggerName, int loggerIndex)
loggerName
- the component that identifies the trace loggerloggerIndex
- the index value to be associated with the specified name.public static final com.ibm.ras.RASTraceLogger getTraceLogger(int loggerIndex)
loggerIndex
- the component that has previously been associated with a trace logger.