日志记录跟踪普通的 CM Server 和 CM API 用户操作以及 CM Server 或基于 CM API 的应用程序运行时发生的所有错误。日志条目使用计算机的缺省语言环境,如果不支持计算机的语言环境,那么使用美国英语。
缺省情况下,对 CM Server 的日志记录设置为 INFO 级别。应对基于 CM API 的应用程序启用 INFO 级别的日志记录。
可配置 CM API、WebSphere® Application Server 和 TSlogger 日志记录软件包。
使用位于用来运行应用程序的 JRE 的 JDK 目录结构中的 logging.properties 文件来控制 CM API 日志记录。请在 JDK 的 jre\lib 目录内查找 logging.properties 文件(例如,C:\Program Files\IBM\WebSphere\AST\eclipse\jre\lib、C:\jdk_5.0\jre\lib 或 C:\Program Files\Java\jre1.5.0_06\lib)。
缺省情况下禁用日志记录;应将它启用为 INFO 级别。
############################################################ # 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。
java -Djava.util.logging.config.file=C:\myLogPropsFile.properties your_client_java_program_that_uses_CM-API
http://<server-name>:<admin-console-port-number>/ibm/console其中,<server-name> 是 CM Server 系统的名称,<admin-console-port> 则是管理控制台端口号(缺省情况下,CM Server 为 12060,而其他 WebSphere Application Server 版本则为 9060)。
可能可以在无需停止并重新启动 CM Server 的情况下实时进行更改,具体取决于 CM Server 系统上使用的 Websphere Application Server 类型。大多数管理控制台的日志记录设置页面上有两个选项卡:配置选项卡和运行时选项卡。
从管理控制台单击故障诊断 -> 日志记录和跟踪,然后从服务器列表选择要配置的服务器。 选择更改日志详细级别,然后单击运行时选项卡。对运行时选项卡所作更改在您保存更改之后立即生效;而对配置选项卡所作更改在重新启动服务器之后才生效。如果希望保留更改,请选中同时将运行时更改保存到配置复选框。选择组件链接。请注意 *=info 已经在框中列出。打开 com.ibm.rational.* 选项并选择 com.ibm.rational.stp.*。通过单击消息和跟踪级别选项选择级别。单击确定,然后在打开的页面顶部的消息区域中,单击保存链接。无需重启服务器,更改即生效。
如果 CM Server 系统上的 Websphere Application Server 的版本或类不提供用于启用实时配置更改的“运行时”选项卡,请使用“配置”选项卡,然后重新启动服务器,以使保存的更改生效。
tslogger.properties 文件具有带标签的区域,可以在这些区域进行更改,这些区域也是可接受值的范围所在。缺省情况下,记录在 INFO 级别上启用。所有 INFO、WARNING 和 SEVERE 消息都会记录到日志文件中。通过编辑 tslogger.properties 文件来配置日志文件,但该文件已在安装时正确配置,无需更改。
tslogger.properties 文件中的缺省设置已设为无需任何修改的值。输出文件填满之后,输出将循环到下一个文件。达到循环中的最大文件数之后,将除去时间最久的文件,以便为循环中的下一个文件腾出空间。