イベント・ロギング
モニター機能および診断機能の一部として、WebSphere® Application Server Liberty は、要求を追跡するために、Java Platform, Enterprise Edition の各種コンポーネントでさまざまなイベントを生成します。eventLogging-1.0 フィーチャーは、アプリケーション要求の実行中にそのようなイベントをログに記録します。このフィーチャーを使用すると、ユーザーは WebSphere Application Server Liberty で実行されている要求を追跡できます。各要求は、要求 ID と呼ばれる固有の相関関係子と、ユーザーが要求固有のデータを理解するのに役立つコンテキスト情報に関連付けられています。
イベント・ロギング・フィーチャーは、サーバー構成によって制御されます。このフィーチャーは、server.xml ファイルで構成します。
[12/15/14 18:24:29:528 IST] 0000002e EventLogging I BEGIN requestID=AAY6TalVDTO_AAAAAAAAAAK # eventType=websphere.servlet.service # contextInfo=TradeWeb | TradeScenarioServlet
[12/15/14 18:24:29:531 IST] 0000002e EventLogging I BEGIN requestID=AAY6TalVDTO_AAAAAAAAAAK # eventType=websphere.servlet.service # contextInfo=TradeWeb | TradeAppServlet
[12/15/14 18:24:29:532 IST] 0000002e EventLogging I BEGIN requestID=AAY6TalVDTO_AAAAAAAAAAK # eventType=websphere.servlet.service # contextInfo=TradeWeb | /quote.jsp
[12/15/14 18:24:29:533 IST] 0000002e EventLogging I BEGIN requestID=AAY6TalVDTO_AAAAAAAAAAK # eventType=websphere.servlet.service # contextInfo=TradeWeb | /displayQuote.jsp
[12/15/14 18:24:29:534 IST] 0000002e EventLogging I BEGIN requestID=AAY6TalVDTO_AAAAAAAAAAK # eventType=websphere.datasource.psExecuteQuery # contextInfo=jdbc/TradeDataSource | select * from quoteejb q where q.symbol=?
[12/15/14 18:24:29:547 IST] 0000002e EventLogging I END requestID=AAY6TalVDTO_AAAAAAAAAAK # eventType=websphere.datasource.psExecuteQuery # contextInfo=jdbc/TradeDataSource | select * from quoteejb q where q.symbol=? # duration=12.537ms
[12/15/14 18:24:29:556 IST] 0000002e EventLogging I END requestID=AAY6TalVDTO_AAAAAAAAAAK # eventType=websphere.servlet.service # contextInfo=TradeWeb | /displayQuote.jsp # duration=22.171ms
[12/15/14 18:24:29:671 IST] 0000002e EventLogging I BEGIN requestID=AAY6TalVDTO_AAAAAAAAAAK # eventType=websphere.servlet.service # contextInfo=TradeWeb | /displayQuote.jsp
[12/15/14 18:24:29:672 IST] 0000002e EventLogging I BEGIN requestID=AAY6TalVDTO_AAAAAAAAAAK # eventType=websphere.datasource.psExecuteQuery # contextInfo=jdbc/TradeDataSource | select * from quoteejb q where q.symbol=?
[12/15/14 18:24:29:677 IST] 0000002e EventLogging I END requestID=AAY6TalVDTO_AAAAAAAAAAK # eventType=websphere.datasource.psExecuteQuery # contextInfo=jdbc/TradeDataSource | select * from quoteejb q where q.symbol=? # duration=4.968ms
[12/15/14 18:24:29:684 IST] 0000002e EventLogging I END requestID=AAY6TalVDTO_AAAAAAAAAAK # eventType=websphere.servlet.service # contextInfo=TradeWeb | /displayQuote.jsp # duration=12.569ms
[12/15/14 18:24:29:685 IST] 0000002e EventLogging I END requestID=AAY6TalVDTO_AAAAAAAAAAK # eventType=websphere.servlet.service # contextInfo=TradeWeb | /quote.jsp # duration=152.752ms
[12/15/14 18:24:29:686 IST] 0000002e EventLogging I END requestID=AAY6TalVDTO_AAAAAAAAAAK # eventType=websphere.servlet.service # contextInfo=TradeWeb | TradeAppServlet # duration=154.616ms
[12/15/14 18:24:29:687 IST] 0000002e EventLogging I END requestID=AAY6TalVDTO_AAAAAAAAAAK # eventType=websphere.servlet.service # contextInfo=TradeWeb | TradeScenarioServlet # duration=158.283ms
要求は、BEGIN websphere.servlet.service "contextInfo=TradeWeb | TradeScenarioServlet" イベント (サンプル・コードの最初の行を参照) で開始し、END websphere.servlet.service "contextInfo=TradeWeb | TradeScenarioServlet" (サンプル・コードの最後の行を参照) で終了しています。最後にこの要求にかかる合計時間も表示されます (このサンプル・コードでは 158.283 ミリ秒)。
メイン要求の BEGIN および END を確認することで、子要求を確認できます。また、各子要求にかかった時間も表示されています。
パフォーマンスを最適化するため、イベント・ロギングを有効にする場合は、バイナリー・ロギングを使用することをお勧めします。イベント・ログ項目の eventType、contextInfo、および requestID の各属性は、ログ・レコード拡張として保管されます。これらのログ・レコード拡張を使用して、binaryLog コマンドでログをフィルターに掛けることができます。
messages.log ファイル内のイベント・ログ項目の解析
イベント・ログは、以下のフォーマットでイベントの情報を取り込みます。[Log mode] [Request Identifier] # [Event Type] # [Context Information] # [Duration] (optional)
各部の意味は、次のとおりです。- ログ・モードは、イベントの開始または終了時のいずれにログが記録されたのかを示します。BEGIN はイベントの開始を示し、END はイベントの終了を示します。
- 要求 ID は、各要求に割り当てられた固有のストリングです。これは、特定の要求に属するイベントのフィルターに使用することができます。例: requestId=AAY6TalVDTO_AAAAAAAAAAK
- イベント・タイプはイベント・ソースに関する情報を提供し、以下の表で示されている、サポートされるイベント・タイプのいずれかを指定できます。イベント・タイプは、特定タイプのイベントのフィルターに使用することができます。例: eventType=websphere.servlet.service
- イベントのコンテキスト情報は、イベント・タイプに関連する詳細を提供します。この情報はイベント・タイプによって異なります。コンテキスト情報は、複数のセクションを含むことができ、「 | 」(スペース|スペース) で区切られます。さまざまなイベント・タイプのコンテキスト情報の例を、以下の表に示しています。
- Duration は、イベントでかかった所要時間を示します。所要時間は、終了イベント項目でのみ表示されます。次の例を参照してください。duration=158.283ms
[12/15/14 18:24:29:687 IST] 0000002e EventLogging I END requestID=AAY6TalVDTO_AAAAAAAAAAK # eventType=websphere.servlet.service # contextInfo=TradeWeb | TradeScenarioServlet # duration=158.283ms
以下の表では、イベント・ロギングでサポートされるイベント・タイプをリストします。コンポーネント | イベント・タイプ | コンテキスト情報 | 例 |
---|---|---|---|
Servlet |
websphere.servlet.destroy |
[Application Name] | [Servlet Name] | [Path Information] | [Query String] |
contextInfo=TradeWeb | /displayQuote.jsp |
Session |
websphere.session.dbSessionDestroyedByTimeout, websphere.session.getAttribute |
[Session Id] [Session Id] | [Session Attribute Name] |
contextInfo=EuitabHZUOD7J2u01HDdAG0 contextInfo=EuitabHZUOD7J2u01HDdAG0 | userID |
JDBC |
websphere.datasource.execute |
[Jndi Name Of Data Source] | [SQL Query] |
contextInfo=jdbc/TradeDataSource | select * from quoteejb q where q.symbol=? |