統合モード、スタンドアロン・モード、 または結合モードで JRas 拡張を使用することができます。 アプリケーションの構成は操作モードによって異なりますが、 メッセージまたはトレース項目を記録するためのロガーの使用法は、 どの操作モードでも同じです。
非推奨: このタスクおよびそのサブタスクで説明する JRas フレームワークは、推奨されません。 しかし、Java ロギングを使用して、同様の結果を得ることができます。
統合モードは、デフォルトの操作モードです。このモードでは、メッセージ・イベントおよびトレース・イベントは WebSphere Application Server のログに送信されます。
結合モードでは、メッセージ・イベントおよびトレース・イベントは、 WebSphere Application Server のログとユーザー定義ログの両方に記録されます。
スタンドアロン・モードでは、メッセージ・イベントおよびトレース・イベントは、 ユーザー定義のログにのみ記録されます。
操作モードに関係なく、メッセージ・ロガーとトレース・ロガーの使い方は同じです。
msgLogger.message(RASIMessageEvent.TYPE_WARNING, this, methodName, "MSG_KEY_00"); ... msgLogger.message(RASIMessageEvent.TYPE_WARN, this, methodName, "MSG_KEY_01", "some string");
msgLogger.msg(RASIMessageEvent.TYPE_ERR, this, methodName, "ALT_MSG_KEY_00", "alternateMessageFile");
msgLogger.textMessage(RASIMessageEvent.TYPE_INFO, this, methodName, "String and Integer", "A String", new Integer(5));
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 you gather parameters to trace. if (trcLogger.isLoggable(RASITraceEvent.TYPE_ENTRY_EXIT) { // I want to trace three parameters, package them up in an Object[] Object[] parms = {new Integer(x), y, z}; trcLogger.entry(RASITraceEvent.TYPE_ENTRY_EXIT, this, "methodX", parms); } ... logic // a debug or verbose trace point if (trcLogger.isLoggable(RASITraceEvent.TYPE_MISC_DATA) { trcLogger.trace(RASITraceEvent.TYPE_MISC_DATA, this, "methodX" "reached here"); } ... // Another classification of trace event. An important state change is detected, so a different trace type is used. if (trcLogger.isLoggable(RASITraceEvent.TYPE_SVC) { trcLogger.trace(RASITraceEvent.TYPE_SVC, this, "methodX", "an important event"); } ... // ready to exit method, trace. No return value to trace if (trcLogger.isLoggable(RASITraceEvent.TYPE_ENTRY_EXIT)) { trcLogger.exit(RASITraceEvent.TYPE_ENTRY_EXIT, this, "methodX"); } }