配置 CM API 日志记录

可以配置 Change Management(CM)API 日志记录。

关于此任务

通过使用与运行应用程序的 JRE 关联的 logging.properties 文件,可以控制 CM API 日志记录。 logging.properties 文件位于 JDK 的目录 jre\lib 中;例如,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. 
#
# 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 20 files, each file being
# limited to 20000000 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 = 20000000
com.ibm.rational.stp.common.internal.util.LogHandler.count = 20
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.  
#
# 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 20 files, each file being
# limited to 20000000 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 = 20000000
#com.ibm.rational.stp.common.internal.util.TraceHandler.count = 20
#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 的日志文件,其中 [#] 指定文件循环号。 每个文件都位于已登录用户的 HOME 目录中;输出将随着每个文件变满而在文件之间循环。

使用上述示例中的 logging.properties 条目指定日志记录追加到适用文件的结尾,并且每个条目以简单格式存储。 要识别对该文件执行的更改,必须停止并重新启动该应用程序。

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

有关如何配置 Java 日志记录的更多信息,请参阅与 JDK 关联的 Javadoc 文档 java.util.logging.Loggerjava.util.logging.FileHandler

如果要创建定制日志属性文件,那么必须使用 -D 参数指定该文件的位置。例如:

java -Djava.util.logging.config.file=C:\myLogPropsFile.properties your_client_java_program_that_uses_CM-API

反馈