使用缺省事件工厂生成公共基本事件内容

缺省公共基本事件内容处理程序使用 WebSphere® Application Server 运行时信息填充公共基本事件。此内容处理程序还可以使用公共基本事件模板来填充公共基本事件。

当服务器创建 CommonBaseEventLogRecords 时将使用缺省内容处理程序,以下示例中也一样:
// Get a named logger
Logger logger = Logger.getLogger("com.ibm.someLogger");
// Log to the logger -- implicitly the default content handler
// will be associated with the CommonBaseEvent contained in the
// CommonBaseEventLogRecord. 
logger.warning("MSG_KEY_001");
如果要在以上情况下指定公共基本事件模板,那么需要为 com.ibm.someLogger 提供带有 eventfactory 条目的 Logger.properties 文件。如果类路径上存在有效模板,那么在填充公共基本事件时,记录器的事件工厂将使用所指定模板的内容和 WebSphere Application Server 运行时信息。如果类路径上没有模板或者模板无效,那么在填充公共基本事件时,记录器的事件工厂将仅使用 WebSphere Application Server 运行时信息。
缺省内容处理程序也将与全局事件工厂上下文中提供的事件工厂 Home 相关联。对于需要使用与 WebSphere Application Server 中所生成内容相类似的内容进行填充的公共基本事件,这是一种方便的创建方法。
// Request the event factory from the global event factory home
EventFactory eventFactory =
   EventFactoryContext.getInstance().getEventFactoryHome().getEventFactory(templateName);

// Create a Common Base Event
CommonBaseEvent commonBaseEvent = eventFactory.createCommonBaseEvent();

// Complete the Common Base Event using content from the template (if specified previously)
// and the server runtime information.
eventFactory.getContentHandler().completeEvent(commonBaseEvent);
在以上示例中,如果 templateName 引用的模板位于类路径上,并且该模板有效,那么事件工厂 Home 将返回一个事件工厂,在填充公共基本事件时,该事件工厂使用的内容处理程序会将模板内容与 WebSphere Application Server 运行时信息组合到一起。如果类路径上没有模板或者模板无效,那么事件工厂 Home 将返回使用内容处理程序的事件工厂,该内容处理程序在填充公共基本事件时仅使用 WebSphere Application Server 运行时信息。

缺省内容处理程序使用以下运行时信息来填充服务器环境中的公共基本事件:

CommonBaseEvent.globalInstanceId
值:unique_record_id

在调用 completeEvent 方法之前,仅当 CommonBaseEvent.globalInstanceId 值为空时才设置此值。

CommonBaseEvent.msg
值:基于 MsgDataElement 元素的本地化消息。

在调用 completeEvent 方法之前,仅当 CommonBaseEvent.msg 消息为空时才设置此值。

CommonBaseEvent.severity
值:根据 CommonBaseEventLogRecord 记录上设置的级别值来进行设置,如果级别大于或等于 Level.SEVERE,那么设置为 50;如果级别大于或等于 Level.WARNING,那么设置为 30;缺省设置为 10

在调用 completeEvent 方法之前,仅当 CommonBaseEvent.severity 值为空时才设置此值。

CommonBaseEvent.ComponentIdentification.component
值:根据 CommonBaseEventLogRecord 记录上设置的 LoggerName 值来进行设置。

在调用 completeEvent 方法之前,仅当 CommonBaseEvent.ComponentIdentification.component 为空时才设置此值。

CommonBaseEvent.ComponentIdentification.componentIdType
值:“Unknown”

在调用 completeEvent 方法之前,仅当 CommonBaseEvent.ComponentIdentification.componentIdType 值为空时才设置此值。

CommonBaseEvent.ComponentIdentification.executionEnvironment
值:OSname[OSarch]#OSversion

在调用 completeEvent 方法之前,仅当 CommonBaseEvent.ComponentIdentification.executionEnvironment 值为空时才设置此值。

CommonBaseEvent.ComponentIdentification.instanceId
值:cellName\nodeName\serverName

在调用 completeEvent 方法之前,仅当 CommonBaseEvent.ComponentIdentification.instanceId 值为空时才设置此值。因为此值在客户机应用程序中会被忽略,所以仅在服务器环境中设置此值。

CommonBaseEvent.ComponentIdentification.location
值:主机名

在调用 completeEvent 方法之前,仅当 CommonBaseEvent.ComponentIdentification.location 值和 CommonBaseEvent.ComponentIdentification.locationType 值都为空时,才设置此值。

CommonBaseEvent.ComponentIdentification.locationType
值:主机名

在调用 completeEvent 方法之前,仅当 CommonBaseEvent.ComponentIdentification.location 值和 CommonBaseEvent.ComponentIdentification.locationType 值都为空时,才设置此值。

CommonBaseEvent.ComponentIdentification.processId
值:进程编号的内部生成表示法。

在调用 completeEvent 方法之前,仅当 CommonBaseEvent.ComponentIdentification.processId 值为空时,才设置此值

CommonBaseEvent.ComponentIdentification.subComponent
值:根据 CommonBaseEventLogRecord 记录的 sourceClassName.sourceMethodName 名称上设置的 sourceClassName 名称和 sourceMethodName 名称值来进行设置。

在调用 completeEvent 方法并设置 sourceClassName 名称和 sourceMethodName 名称之前,仅当 CommonBaseEvent.ComponentIdentification.subComponent 值为空时,才设置此值。

CommonBaseEvent.ComponentIdentification.threadId
值:设置为 Java™ 虚拟机 (JVM) 线程名称的值。

在调用 completeEvent 值之前,仅当 CommonBaseEvent.ComponentIdentification.threadId 值为空时才设置此值。

CommonBaseEvent.ComponentIdentification.componentType
值:http://www.ibm.com/namespaces/autonomic/WebSphereApplicationServer

在调用 completeEvent 方法之前,仅当 CommonBaseEvent.ComponentIdentification.componentType 值为空时才设置此值。

CommonBaseEvent.MsgDataElement.msgLocale
值:根据 JVM 的缺省语言环境来进行设置。

在调用 completeEvent 方法之前,仅当 CommonBaseEvent.msg 值为空时才设置此值。

CommonBaseEvent.Situation.categoryName
值:ReportSituation

在调用 completeEvent 方法之前,仅当 CommonBaseEvent.Situation 值为空时才设置此值。

CommonBaseEvent.Situation.situationType.type
值:ReportSituation

在调用 completeEvent 方法之前,仅当 CommonBaseEvent.Situation 值为空时才设置此值。

CommonBaseEvent.Situation.situationType.reasoningScope
值:EXTERNAL

在调用 completeEvent 方法之前,仅当 CommonBaseEvent.Situation 值为空时才设置此值。

CommonBaseEvent.Situation.situationType.reportCategory
值:LOG

在调用 completeEvent 方法之前,仅当 CommonBaseEvent.Situation 值为空时才设置此值。

如果在内容处理程序上调用 completeEvent 方法时不存在任何 reporterComponentIdentification 标识,那么填充 sourceComponentIdentification 值。否则,将填充 reporterComponentIdentification 标识。


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



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