CM API ロギングの構成

変更管理 (CM) API ロギングを構成できます。
このタスクについて

CM API ロギングは、ユーザーのアプリケーションを実行している JRE に関連付けられた logging.properties ファイルを使用して制御されます。 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. 
#
# 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 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.  
#
# 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 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 項目を使用すると、 ログ レコードが該当するファイルの最後に付加され、 それぞれの項目が単純なフォーマットで保管されるように指定されます。logging.properties ファイルへの変更は、 CM API ベースのアプリケーションによって約 10 秒以内に認識されます。 アプリケーションを停止して再始動する必要はありません。

ログ出力ファイルがいっぱいになると、 新規ファイルが作成され、前のファイルはファイルのローテーションが行われた日付とタイム スタンプを含む名前に変更されます。 各ファイルは 20 MB のデータを保持し、既存の項目に新規項目が追加されます。 これは、アプリケーションの再始動の間も行われます。ログ ファイルの数が 20 個に達すると、 新規ファイルへのローテーションにより一番古いファイルが削除されます。

Java ロギングの構成方法について詳しくは、JDK に関連する Javadoc 資料の java.util.logging.Logger および java.util.logging.FileHandler を参照してください。

カスタム ログ プロパティ ファイルを作成する場合、 -D 引数を使用することによって、ロケーションを JVM に指定する必要があります。 例えば、次のようになります。
java -Djava.util.logging.config.file=C:¥myLogPropsFile.properties your_client_java_program_that_uses_CM-API

フィードバック