事件日志记录
作为监视和诊断功能的一部分,WebSphere Application Server Liberty 在 Java Platform Enterprise Edition 的各个组件中生成事件以跟踪请求。应用程序请求运行时,eventLogging-1.0 功能部件会记录这类事件。通过使用此功能部件,用户可跟踪正在 WebSphere Application Server Liberty 中运行的请求。每个请求与唯一相关因子(称为请求标识)及上下文信息相关联,上下文信息帮助用户了解特定于该请求的数据。
Event Logging 功能部件是通过服务器配置控制的。此功能部件是在 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 ms)。
可通过查看主请求的 BEGIN 和 END 来查看子请求。还可找到每个子请求耗用的时间。
为获得最佳性能,可在启用事件日志记录时使用二进制日志记录。事件日志条目中的 eventType、contextInfo 和 requestID 属性存储为日志记录扩展。可使用这些日志记录扩展以借助 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
[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 |
会话 |
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=? |