通用日志适配器提供了一个输出程序类,该类可以将适配器生成的公共基本事件对象发送至记录代理程序。可使用“日志和跟踪分析器”来连接至记录代理程序以便以实时方式监视和分析应用程序日志。
先决条件:执行下列步骤来配置适配器,以便进行监视。
注意:当创建新的适配器配置文件时,缺省情况下会将它配置为使用 CBELogOutputter 类。如果您未更改此设置,则可以跳过此过程。
您需要将适配器配置文件中的输出程序组件更新为使用 CBELogOutputter 类,该类将公共基本事件对象写至记录代理程序。您可以更新现有的输出程序组件,也可以添加新的输出程序组件。
要添加新的输出程序组件:
名称: | 上下文中的输出程序名称 |
描述: | 对此输出程序执行的任务的描述 |
可执行的类: | org.eclipse.hyades.logging.adapter.outputters.CBELogOutputter |
记录级别: | 输出程序组件应使用的内部记录级别。
值 99 表示输出程序将不记录任何消息。 值 0 表示输出程序将记录所有严重性的消息。 建议值是 50,这表示只记录“紧急”或“致命”内部输出程序错误消息。 |
角色: | 输出程序 |
唯一标识: | 必须指向步骤 3 中在“上下文实例”中定义的输出程序。使用浏览按钮来选择正确的标识。 |
如果要让日志解析器连续地监视日志文件,则需要更新适配器配置文件的上下文实例属性以执行连续操作。
可以从批处理文件(在 Windows 环境中)或 shell 脚本(在非 Windows 环境中)以外部方式运行您创建的日志适配器。下列样本文件可用来启动将运行日志适配器的 Java 进程。
注意:要连接并监视由通用日志适配器创建的记录代理程序,必须在要运行通用日志适配器的系统上安装 Hyades 代理控制器,并且必须在启动通用日志适配器之前启动该代理控制器。
Windows 批处理文件:
@rem USAGE: runregex @rem PURPOSE: Illustrates the functional capabilities of the Generic Log Adapter (GLA) @rem run-time using an example adapter file and sample log file. @rem ASSUMPTIONS: This batch file assumes the GLA run-time and required files are @rem stored in the following directory structure: @rem %GLA_HOME%\config - GLA adapter configuration files @rem %GLA_HOME%\lib - GLA run-time and required jars @rem %GLA_HOME%\schema - GLA adapter configuration schema files @rem INSTRUCTIONS: @rem If the GLA run-time and required files are stored as indicated in the @rem assumptions section above, change the value of the %GLA_HOME% @rem environment variable to the absolute path where the GLA run-time @rem and required files are stored. @rem If the GLA run-time files are stored in a plug-in (e.g. Eclipse) @rem environment, perform the following instructions: @rem 1) Create a temporary directory to store the GLA run-time and required files. @rem 2) Create the config, lib, and schema directories in the temporary @rem directory creatd in step 1) @rem 3) Change the value of the %GLA_HOME% environment variable to the @rem absolute path of the temporary directory created in step 1) @rem 4) Copy the adapter files you want to run into the %GLA_HOME%\config directory. @rem For example if you want to run the Apache adapter files then copy the @rem Apache directory of the org.eclipse.hyades.logging.adapter.config @rem plug-in and all of its contents to the %GLA_HOME%\config directory. @rem 5) Copy the contents of the schema directory of @rem org.eclipse.hyades.logging.adapter plug-in to the %GLA_HOME%\schema directory. @rem 6) Copy the following jar files to the %GLA_HOME%\lib directory @rem Plug-in | JAR @rem --------------------------------------------------- @rem org.eclipse.hyades.logging.adapter | hgla.jar @rem org.eclipse.hyades.logging.core | hlcbe101.jar @rem org.eclipse.hyades.logging.core | hlcore.jar @rem org.eclipse.hyades.execution.remote | hexr.jar @rem org.eclipse.emf.ecore | ecore.jar @rem org.eclipse.emf.common | common.jar SET GLA_HOME=d:\GenericLogAdapter SET CONFIG_FILE=%GLA_HOME%\config\my.adapter @PUSHD %GLA_HOME%\config\ java -DGLA_HOME="%GLA_HOME%" -classpath "%GLA_HOME%\lib\hgla.jar;%GLA_HOME%\lib\hexr.jar;%GLA_HOME%\lib\hlcbe101.jar;%GLA_HOME%\lib\ecore.jar;%GLA_HOME%\lib\common.jar;%GLA_HOME%\lib\hlcore.jar" org.eclipse.hyades.logging.adapter.Adapter -ac "%CONFIG_FILE%" -cc "%CONFIG_FILE%" POPD非 Windows 批处理文件:
#!/bin/sh # USAGE: runregex.sh # PURPOSE: Illustrates the functional capabilities of the Generic Log Adapter (GLA) # run-time using an example adapter file and sample log file. # ASSUMPTIONS: This shell file assumes the GLA run-time and required files are # stored in the following directory structure: # %GLA_HOME%/config - GLA adapter configuration files # %GLA_HOME%/lib - GLA run-time and required jars # %GLA_HOME%/schema - GLA adapter configuration schema files # INSTRUCTIONS: # If the GLA run-time and required files are stored as indicated in the # assumptions section above, change the value of the %GLA_HOME% # environment variable to the absolute path where the GLA run-time # and required files are stored. # If the GLA run-time files are stored in a plug-in (e.g. Eclipse) # environment, perform the following instructions: # 1) Create a temporary directory to store the GLA run-time and required files. # 2) Create the config, lib, and schema directories in the temporary # directory creatd in step 1) # 3) Change the value of the %GLA_HOME% environment variable to the # absolute path of the temporary directory created in step 1) # 4) Copy the adapter files you want to run to the %GLA_HOME%/config directory. # For example, if you want to run the Apache adapter files then copy the # Apache directory of the org.eclipse.hyades.logging.adapter.config # plug-in and all of its contents to the %GLA_HOME%/config directory. # 5) Copy the contents of the schema directory of # org.eclipse.hyades.logging.adapter plug-in to the %GLA_HOME%/schema directory. # 6) Copy the following jar files to the %GLA_HOME%/lib directory # Plug-in | JAR # --------------------------------------------------- # org.eclipse.hyades.logging.adapter | hgla.jar # org.eclipse.hyades.logging.core | hlcbe101.jar # org.eclipse.hyades.logging.core | hlcore.jar # org.eclipse.hyades.execution.remote | hexr.jar # org.eclipse.emf.ecore | ecore.jar # org.eclipse.emf.common | common.jar GLA_HOME=/home/eclipse/GenericLogAdapter export GLA_HOME CONFIG_FILE="$GLA_HOME/config/my.adapter" export CONFIG_FILE CUR_DIR=`pwd` export CUR_DIR cd "$GLA_HOME/config" java -DGLA_HOME="$GLA_HOME" -classpath "$GLA_HOME/lib/hgla.jar:$GLA_HOME/lib/hexr.jar:$GLA_HOME/lib/hlcbe101.jar:$GLA_HOME/lib/ecore.jar:$GLA_HOME/lib/common.jar:$GLA_HOME/lib/hlcore.jar" org.eclipse.hyades.logging.adapter.Adapter -ac "$CONFIG_FILE" -cc "$CONFIG_FILE" cd "$CUR_DIR"根据需要配置文件以启动将运行适配器的 Java 进程。
您现在可以监视活动应用程序日志了。
相关概念
通用日志适配器概述
公共基本事件格式规范
相关任务
创建日志解析器
相关参考
适配器配置文件结构
适配器配置编辑器
正则表达式语法
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.