Red Hat Training

A Red Hat training course is available for Red Hat JBoss Enterprise Application Platform

12.3.9. CLI でのカスタムハンドラーの設定

カスタムハンドラーは CLI で追加、削除、および編集できます。
カスタムハンドラーを設定するために実行する主なタスクは以下のとおりです。
  • 新しいカスタムハンドラーを追加します。
  • カスタムハンドラーの設定表示
  • ログレベルを設定します。
  • カスタムハンドラーの削除
重要
カスタムハンドラーをスタンドアロンシステムのロギングプロファイルに設定する場合、設定パスのルートは /subsystem=logging/ ではなく /subsystem=logging/logging-profile=NAME/ になります。
管理対象ドメインでは、使用するプロファイルを指定する必要があります。管理対象ドメインの設定パスの先頭にプロファイル名を追加する必要があります。/subsystem=logging//profile=NAME/subsystem=logging/ に置き換えます。
新しいカスタムハンドラーの追加
以下の構文で add 操作を使用します。
/subsystem=logging/custom-handler="MyCustomHandler":add

例12.75 新しいカスタムハンドラーの追加

[standalone@localhost:9999 /] /subsystem=logging/custom-handler="MyCustomHandler":add(class="JdbcLogger",module="com.MyModule",formatter="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",properties={"maxNumberOfDays"=>"90","fileName"=>"custom.log","compressBackups"=>"true"})
カスタムハンドラーの表示
以下の構文で read-resource 操作を使用します。CUSTOMHANDLER をカスタムハンドラーの名前に置き換えます。
/subsystem=logging/custom-handler=CUSTOMHANDLER:read-resource

例12.76 カスタムハンドラー設定の表示

[standalone@localhost:9999 /] /subsystem=logging/custom-handler="MyCustomHandler":read-resource
{
    "outcome" => "success",
    "result" => {
        "autoflush" => true,
        "enabled" => true,
        "encoding" => undefined,
        "filter" => undefined,
        "filter-spec" => undefined,
        "formatter" => "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",
        "level" => "INFO",
        "name" => "CONSOLE",
        "named-formatter" => "COLOR-PATTERN",
        "target" => "System.out"
    }
}
ログレベルの設定
次の構文で write-attribute 操作を使用します。CUSTOMHANDLER はログカテゴリーの名前に、LEVEL は設定するログレベルに置き換えます。
/subsystem=logging/custom-handler=CUSTOMHANDLER:write-attribute(name="level", value="INFO") 

例12.77 ログレベルの設定

[standalone@localhost:9999 /] /subsystem=logging/custom-handler="MyCustomHandler":write-attribute(name="level", value="TRACE")
{"outcome" => "success"}
カスタムハンドラーの削除
以下の構文で remove 操作を使用します。CUSTOMHANDLER を、削除するカスタムハンドラーの名前に置き換えます。
/subsystem=logging/custom-handler=CUSTOMHANDLER:remove

例12.78 カスタムハンドラーの削除

[standalone@localhost:9999 /] /subsystem=logging/custom-handler="MyCustomHandler":remove
{"outcome" => "success"}