
![[8.5.5.6 或更新版本]](../ng_v8556.gif)
事件記載
在監視和診斷功能中,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 檔中的事件日誌項目
事件日誌會以下列格式擷取事件資訊:[日誌模式] [要求 ID] # [事件類型] # [環境定義資訊] # [持續時間](選用)
其中-「日誌模式」指出要在進入事件還是結束事件時記錄日誌。BEGIN
表示進入事件,END 表示結束事件。-「要求 ID」是指派給每一項要求的唯一字串。這可用來過濾屬於特定要求的事件。範例:requestId=AAY6TalVDTO_AAAAAAAAAAK
-「事件類型」提供事件來源的相關資訊,可以是下表所提供的任何支援的事件類型。事件類型可用來過濾特定類型的事件。範例:eventType=websphere.servlet.service
- 事件的環境定義資訊提供該事件類型的相關詳細資料。資訊會因事件類型而有不同。環境定義資訊可以包含多個區段,並以 | 區隔(空格|空格)。下表提供各種事件類型的環境定義資訊。-「持續時間」指出事件所耗費的時間。持續時間只會出現在結束事件項目中。範例: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 |
[應用程式名稱] | [Servlet 名稱] | [路徑資訊] | [查詢字串] |
contextInfo=TradeWeb | /displayQuote.jsp |
階段作業 |
websphere.session.dbSessionDestroyedByTimeout, websphere.session.getAttribute |
[階段作業 ID] [階段作業 ID] | [階段作業屬性名稱] |
contextInfo=EuitabHZUOD7J2u01HDdAG0 contextInfo=EuitabHZUOD7J2u01HDdAG0 | userID |
JDBC |
websphere.datasource.execute |
[資料來源的 JNDI 名稱名稱] | [SQL 查詢] |
contextInfo=jdbc/TradeDataSource | select * from quoteejb q where q.symbol=? |