ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzatz_5.4.0.1/51/program/jrascrtml.htm

77 lines
4.1 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK rel="stylesheet" type="text/css" href="../../../rzahg/ic.css">
<title>Create JRas manager and logger instances</title>
</head>
<BODY>
<!-- Java sync-link -->
<SCRIPT LANGUAGE="Javascript" SRC="../../../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
<h5><a name="jrascrtml"></a>Create JRas manager and logger instances</h5>
<p>You can use the JRas extensions in integrated, standalone, or combined mode. Configuration of the application will vary depending on the mode of operation, but usage of the loggers to log message or trace entries is identical in all modes of operation.</p>
<p>Integrated mode is the default mode of operation. In this mode, message and trace events are sent to the WebSphere Application Server - Express logs. See <a href="jraseti.htm">Set up for integrated JRas operation</a> for information on configuring for this mode of operation.</p>
<p>In the combined mode, message and trace events are logged to both WebSphere Application Server - Express and user-defined logs. See <a href="jrasetc.htm">Set up for combined JRas operation</a> for more information on configuring for this mode of operation.</p>
<p>In the standalone mode, message and trace events are logged only to user-defined logs. See <a href="jrasets.htm">Set up for standalone JRas operation</a> for more information on configuring for this mode of operation.</p>
<p><strong>Using the message and trace loggers</strong></p>
<p>Regardless of the mode of operation, the use of message and trace loggers is the same. See <a href="jrascrtrb.htm">Create JRas resource bundles and message files</a> for more information on using message and trace loggers.</p>
<p><strong>Using a message logger</strong></p>
<p>The message logger is configured to use the DefaultMessages resource bundle. Message keys must be passed to the message loggers if the loggers are using the message() API.</p>
<pre>
msgLogger.message(RASIMessageEvent.TYPE_WARNING, this, methodName, &quot;MSG_KEY_00&quot;);
... msgLogger.message(RASIMessageEvent.TYPE_WARN, this, methodName, &quot;MSG_KEY_01&quot;,
&quot;some string&quot;);
</pre>
<p>If message loggers use the msg() API, you can specify a new resource bundle name.</p>
<pre>msgLogger.msg(RASIMessageEvent.TYPE_ERR, this, methodName, &quot;ALT_MSG_KEY_00&quot;,
&quot;alternateMessageFile&quot;);</pre>
<p>You can also log a text message. If you are using the textMessage API, no message formatting is done.</p>
<pre>msgLogger.textMessage(RASIMessageEvent.TYPE_INFO, this, methodName,
&quot;String and Integer&quot;, &quot;A String&quot;, new Integer(5));</pre>
<p><strong>Using a trace logger</strong></p>
<p>Since trace is normally disabled, trace methods should be guarded for performance reasons.</p>
<pre>private void methodX(int x, String y, Foo z) {
// trace an entry point. Use the guard to make sure tracing is enabled.
// Do this checking before we waste cycles gathering parameters to be traced.
if (trcLogger.isLoggable(RASITraceEvent.TYPE_ENTRY_EXIT) {
// since I want to trace 3 parameters, package them up in an Object[]
Object[] parms = {new Integer(x), y, z};
trcLogger.entry(RASITraceEvent.TYPE_ENTRY_EXIT, this, &quot;methodX&quot;, parms);
}
... logic
// a debug or verbose trace point
if (trcLogger.isLoggable(RASITraceEvent.TYPE_MISC_DATA) {
trcLogger.trace(RASITraceEvent.TYPE_MISC_DATA, this, &quot;methodX&quot; &quot;reached here&quot;);
}
...
// Another classification of trace event. Here an important state
// change has been detected, so a different trace type is used.
if (trcLogger.isLoggable(RASITraceEvent.TYPE_SVC) {
trcLogger.trace(RASITraceEvent.TYPE_SVC, this, &quot;methodX&quot;, &quot;an important event&quot;);
}
...
// ready to exit method, trace. No return value to trace
if (trcLogger.isLoggable(RASITraceEvent.TYPE_ENTRY_EXIT)) {
trcLogger.exit(RASITraceEvent.TYPE_ENTRY_EXIT, this, &quot;methodX&quot;);
}
}</pre>
</body>
</html>