Liberty:事件日志记录

作为监视和诊断功能的一部分,WebSphere Application Server Liberty 在 Java Platform Enterprise Edition 的各个组件中生成事件以跟踪请求。应用程序请求运行时,eventLogging-1.0 功能部件会记录这类事件。通过使用此功能部件,用户可跟踪正在 WebSphere Application Server Liberty 中运行的请求。每个请求与唯一相关因子(称为请求标识)及上下文信息相关联,上下文信息帮助用户了解特定于该请求的数据。

Event Logging 功能部件是通过服务器配置控制的。此功能部件是在 server.xml 文件中配置的。

以下样本日志显示对应 AAY6TalVDTO_AAAAAAAAAAK 请求标识和 TradeWeb 上下文的端到端事件日志:
[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 ms)。

可通过查看主请求的 BEGINEND 来查看子请求。还可找到每个子请求耗用的时间。

为获得最佳性能,可在启用事件日志记录时使用二进制日志记录。事件日志条目中的 eventTypecontextInforequestID 属性存储为日志记录扩展。可使用这些日志记录扩展以借助 binaryLog 命令来过滤日志。

解析 messages.log 文件中的事件日志条目

事件日志使用以下格式捕获事件信息:
[Log mode] [Request Identifier] # [Event Type] # [Context Information] # [Duration] (optional)
其中

- Log mode 指示日志是在进入还是退出事件时记录的。BEGIN 指进入事件,END 指退出事件。
- Request identifier 是分配给每个请求的唯一字符串。它可用于过滤属于特定请求的事件。例如:requestId=AAY6TalVDTO_AAAAAAAAAAK
- Event type 提供有关事件源的信息,可以是下表中给定的任何受支持事件类型。事件类型可用于过滤特定类型的事件。示例:eventType=websphere.servlet.service
- Context information 是事件的上下文信息,用于指定与事件类型相关的详细信息。此信息根据事件类型不同而变化。上下文信息可包含多个部分,各部分之间以 | (| 的两边有空格)分隔。下表中给定各种事件类型的上下文信息的示例。
- Duration 指示事件耗用的时间。duration 仅显示在退出事件条目中。示例:duration=158.283ms

除 log mode(以空格分隔)外,所有其他日志属性以 # (# 两边有空格)分隔。例如,
[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
下表列示事件日志记录支持的事件类型:

表 1. 受支持事件类型及相关上下文信息
组件 事件类型 上下文信息 示例

Servlet

websphere.servlet.destroy
websphere.servlet.service

[Application Name] | [Servlet Name] | [Path Information] | [Query String]

contextInfo=TradeWeb | /displayQuote.jsp

会话

websphere.session.dbSessionDestroyedByTimeout,
websphere.session.dbSessionDestroyed
websphere.session.sessionAccessed
websphere.session.sessionCreated
websphere.session.sessionDestroyedByTimeout
websphere.session.sessionDestroyed
websphere.session.sessionLiveCountDec
websphere.session.sessionLiveCountInc
websphere.session.sessionReleased

websphere.session.getAttribute
websphere.session.setAttribute

[Session Id]





[Session Id] | [Session Attribute Name]

contextInfo=EuitabHZUOD7J2u01HDdAG0





contextInfo=EuitabHZUOD7J2u01HDdAG0 | userID

JDBC

websphere.datasource.execute
websphere.datasource.executeQuery
websphere.datasource.executeUpdate
websphere.datasource.psExecute
websphere.datasource.psExecuteQuery
websphere.datasource.psExecuteUpdate
websphere.datasource.rsCancelRowUpdates
websphere.datasource.rsDeleteRow
websphere.datasource.rsInsertRow
websphere.datasource.rsUpdateRow

[Jndi Name Of Data Source] | [SQL Query]

contextInfo=jdbc/TradeDataSource | select * from quoteejb q where q.symbol=?


用于指示主题类型的图标 参考主题



时间戳记图标 最近一次更新时间: Tuesday, 6 December 2016
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=rwlp_eventlogging
文件名:rwlp_eventlogging.html