配置日志记录

日志记录可用于监视和调试 CM Server 和基于 CM API 的应用程序。

日志记录跟踪普通的 CM Server 和 CM API 用户操作以及 CM Server 或基于 CM API 的应用程序运行时发生的所有错误。日志条目使用计算机的缺省语言环境,如果不支持计算机的语言环境,那么使用美国英语。

缺省情况下,对 CM Server 的日志记录设置为 INFO 级别。应对基于 CM API 的应用程序启用 INFO 级别的日志记录。

可配置 CM API、WebSphere® Application Server 和 TSlogger 日志记录软件包。

CM API 日志记录

使用位于用来运行应用程序的 JRE 的 JDK 目录结构中的 logging.properties 文件来控制 CM API 日志记录。请在 JDK 的 jre\lib 目录内查找 logging.properties 文件(例如,C:\Program Files\IBM\WebSphere\AST\eclipse\jre\libC:\jdk_5.0\jre\libC:\Program Files\Java\jre1.5.0_06\lib)。

缺省情况下禁用日志记录;应将它启用为 INFO 级别。

下面的 logging.properties 示例文件包含的条目说明了如何为基于 CM API 的应用程序配置日志和跟踪设置:
############################################################
#      Global properties
############################################################
#
# "handlers" specifies a comma separated list of log Handler 
# classes.  These handlers will be installed during VM startup.
# Note that these classes must be on the system classpath.
# By default we only configure a ConsoleHandler, which will only
# show messages at the INFO and above levels.
handlers = java.util.logging.ConsoleHandler

# To also add the FileHandler, use the following line instead.
#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler

# Default global logging level.
# This specifies which kinds of events are logged across
# all loggers.  For any given facility this global level
# can be overriden by a facility specific level
# Note that the ConsoleHandler also has a separate level
# setting to limit messages printed to the console.
# The next line enables logging (for all logger objects) to occur at the INFO level
.level=INFO

############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################

# CMLogger - Should always be enabled at the INFO level. 
#
# Applications using CM API do not have to be stopped and restarted; changes to the configured

# logging.properties file are automatically noticed and honored within 10 seconds.
#
# The following lines designate logging for the CMLogger object to occur at the INFO level,
# and that the log output file will be named CMLogger[#].log, located in the logged-in
# user's HOME directory; the log output file will rotate through 40 files, each file being
# limited to 40000000 bytes.  Log entries will be appended to the current log output
# file in the rotation and will be written using a simple format.
#
com.ibm.rational.stp.common.internal.util.CMLogger.level = INFO
com.ibm.rational.stp.common.internal.util.LogHandler.pattern = %h/CMLogger%g.log
com.ibm.rational.stp.common.internal.util.LogHandler.limit = 40000000
com.ibm.rational.stp.common.internal.util.LogHandler.count = 40
com.ibm.rational.stp.common.internal.util.LogHandler.append = true
com.ibm.rational.stp.common.internal.util.LogHandler.formatter = java.util.logging.SimpleFormatter

# CMTracer - Enable (uncomment) the entries below for temporary use only, as tracing
# can be resource intensive.  
#
# Applications using CM API do not have to be stopped and restarted; changes to the configured
# logging.properties file are automatically noticed and honored within 10 seconds.
#
# The following lines designate tracing for the CMTracer object to occur at the FINER level,
# and that the trace output file will be named CMTracer[#].log, located in the logged-in
# user's HOME directory; the trace output file will rotate through 40 files, each file being
# limited to 40000000 bytes.  Trace entries will be appended to the current trace output
# file in the rotation and will be written using a simple format.
#
#com.ibm.rational.stp.common.internal.util.CMTracer.level = FINER
#com.ibm.rational.stp.common.internal.util.TraceHandler.pattern = %h/CMTracer%g.log
#com.ibm.rational.stp.common.internal.util.TraceHandler.limit = 40000000
#com.ibm.rational.stp.common.internal.util.TraceHandler.count = 40
#com.ibm.rational.stp.common.internal.util.TraceHandler.append = true
#com.ibm.rational.stp.common.internal.util.TraceHandler.formatter = java.util.logging.SimpleFormatter

这些设置会产生一个名为 CMLogger[#].log 的日志文件(如果对 CMTracer 条目取消了注释,还会产生一个名为 CMTracer[#].log 的跟踪输出文件)。每个文件都位于已登录用户的 HOME 目录中(其中 [#] 指定文件循环号);输出将随着每个文件变满而在文件之间循环。

使用上述 logging.properties 条目即指定日志记录应追加到适用文件的结尾,并且每个条目以简单格式存储。基于 CM API 的应用程序将在约 10 秒内自动注意到并认可对 logging.properties 文件的更改;无需停止并重新启动应用程序。

如果日志输出文件变满(达到 40 MB),将创建一个新文件并重命名上一个文件,以包含发生文件循环时的日期和时间戳记。 每个文件保存 40 MB 的数据,而新条目则附加到现有条目,包括跨应用程序重新启动。如果日志文件数达到 40,循环到新文件将导致自动删除时间最早的文件。

有关如何配置 Java 日志记录的更多信息,请参阅 JDK java.util.logging.Logger 和 java.util.logging.FileHandler Javadoc。

如果创建定制日志记录属性文件,那么必须通过指定 -D 参数来为 JVM 指定查找该文件的位置。例如:
java -Djava.util.logging.config.file=C:\myLogPropsFile.properties your_client_java_program_that_uses_CM-API

配置 WebSphere Application Server 日志记录和跟踪

使用 WebSphere Application Server 管理控制台来设置和配置 WebSphere Application Server 日志记录和跟踪。可使用此 URL 访问 WebSphere Application Server 管理控制台:
http://<server-name>:<admin-console-port-number>/ibm/console
其中,<server-name> 是 CM Server 系统的名称,<admin-console-port> 则是管理控制台端口号(缺省情况下,CM Server 为 12060,而其他 WebSphere Application Server 版本则为 9060)。
注: 在任何级别(FINE、FINER 或 FINEST)上跟踪运行在 WebSphere Application Server 上的组件(包括 CM Server 组件)将对性能产生负面影响。

可能可以在无需停止并重新启动 CM Server 的情况下实时进行更改,具体取决于 CM Server 系统上使用的 Websphere Application Server 类型。大多数管理控制台的日志记录设置页面上有两个选项卡:配置选项卡和运行时选项卡。

从管理控制台单击故障诊断 -> 日志记录和跟踪,然后从服务器列表选择要配置的服务器。 选择更改日志详细级别,然后单击运行时选项卡。对运行时选项卡所作更改在您保存更改之后立即生效;而对配置选项卡所作更改在重新启动服务器之后才生效。如果希望保留更改,请选中同时将运行时更改保存到配置复选框。选择组件链接。请注意 *=info 已经在框中列出。打开 com.ibm.rational.* 选项并选择 com.ibm.rational.stp.*。通过单击消息和跟踪级别选项选择级别。单击确定,然后在打开的页面顶部的消息区域中,单击保存链接。无需重启服务器,更改即生效。

如果 CM Server 系统上的 Websphere Application Server 的版本或类不提供用于启用实时配置更改的“运行时”选项卡,请使用“配置”选项卡,然后重新启动服务器,以使保存的更改生效。

可能需要增加关于日志文件大小和循环日志文件数的初始缺省设置。应将循环日志文件数设置为最小 40,将日志文件大小设置为最小 40 MB。在 Websphere Application Server 管理控制台中,要更改 JVM 日志文件大小和文件循环设置,请执行下列步骤:
  1. 选择故障诊断->日志记录和跟踪
  2. 从服务器列表中选择要配置的相应服务器。
  3. 选择 JVM 日志,然后单击配置选项卡(可使用运行时选项卡查看当前 SystemOut.log 和 SystemErr.log 文件内容)。
  4. 对 SystemOut 和 SystemErr 的位置、文件大小(应该至少为 40 MB)以及要维护的历史记录文件数(应该至少为 40)进行更改。
  5. 单击确定,然后在打开的页面顶部的消息区域中,单击保存链接。
WebSphere Application Server 日志文件位于以下位置:
  • UNIX®/opt/IBM/RationalSDLC/common/CM/profiles/cmprofile/logs/server1/
  • Linux®/opt/ibm/RationalSDLC/common/CM/profiles/cmprofile/logs/server1/
  • Windows®\Program Files\IBM\RationalSDLC\common\CM\profiles\cmprofile\logs\server1\

TSlogger

TSLogger 用于记录后端 ONCRPC 服务器进程。编辑以下位置的 tslogger.properties 文件可配置该实用程序:
  • Windows:\Program Files\IBM\RationalSDLC\common\CM\bin\tslogger.properties
  • UNIX:/opt/IBM/RationalSDLC/common/CM/bin/tslogger.properties
  • Linux:/opt/ibm/RationalSDLC/common/CM/bin/tslogger.properties
日志和跟踪文件位于以下位置:
  • Windows:\Program Files\IBM\RationalSDLC\common\CM\logs\server1\ccrpc [and \cqrpc]
  • UNIX:/opt/IBM/RationalSDLC/common/CM/logs/server1/ccrpc [and /cqrpc]
  • Linux:/opt/ibm/RationalSDLC/common/CM/logs/server1/ccrpc [and /cqrpc]
日志和跟踪文件包括:
  • SystemOut.log - 常规日志输出,缺省情况下启用,以 INFO 级别进行日志记录。
  • SystemErr.log - 错误/异常输出,缺省情况下启用。
  • trace.log - 跟踪输出,缺省情况下禁用。

tslogger.properties 文件具有带标签的区域,可以在这些区域进行更改,这些区域也是可接受值的范围所在。缺省情况下,记录在 INFO 级别上启用。所有 INFO、WARNING 和 SEVERE 消息都会记录到日志文件中。通过编辑 tslogger.properties 文件来配置日志文件,但该文件已在安装时正确配置,无需更改。

tslogger.properties 文件中的缺省设置已设为无需任何修改的值。输出文件填满之后,输出将循环到下一个文件。达到循环中的最大文件数之后,将除去时间最久的文件,以便为循环中的下一个文件腾出空间。

记录级别的摘要从最高到最低依次为:
  • OFF:禁用所有记录和跟踪。
  • ERROR:与 JSR47 中的 SEVERE 对应。
  • WARNING:与 JSR47 中的 WARNING 对应。
  • INFO:与 JSR47 中的 INFO 对应。
  • DEBUG_MIN:与 JSR47 中的 FINE 对应。
  • DEBUG_MID:与 JSR47 中的 FINER 对应。
  • DEBUG_MAX:与 JSR47 中的 FINEST 对应。
  • ALL:启用所有级别的记录和跟踪。
相关概念
ClearQuest 日志文件和日志属性文件

反馈