11.3.3. CLI でのコンソールログハンドラー設定

コンソールログハンドラーは CLI で追加/削除/編集することができます。

手順11.12 コンソールログハンドラーの設定の表示

  • 次の構文で read-resource オペレーションを使用します。HANDLERはコンソールログハンドラーの名前に置き換えます。
     /subsystem=logging/console-handler=HANDLER:read-resource 

    例11.12

    [standalone@localhost:9999 /] /subsystem=logging/console-handler=CONSOLE:read-resource
    {
        "outcome" => "success",
        "result" => {
            "autoflush" => true,
            "encoding" => undefined,
            "filter" => undefined,
            "formatter" => "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",
            "level" => "INFO",
            "target" => "System.out"
        }
    }
    [standalone@localhost:9999 /]
    

手順11.13 コンソールログハンドラーの追加

  • 次の構文で add オペレーションを使用します。HANDLER は追加するコンソールログハンドラーに置き換えます。
     /subsystem=logging/console-handler=HANDLER:add 

    例11.13

    [standalone@localhost:9999 /] /subsystem=logging/console-handler=ERRORCONSOLE:add     
    {"outcome" => "success"}
    [standalone@localhost:9999 /]
    

手順11.14 ログレベルの設定

  • 次の構文で change-log-level オペレーションを使用します。HANDLER はコンソールログハンドラーの名前に、LEVEL は設定するログレベルに置き換えてください。
     /subsystem=logging/console-handler=HANDLER:change-log-level(level="LEVEL") 

    例11.14

    [standalone@localhost:9999 /] /subsystem=logging/console-handler=ERRORCONSOLE:change-log-level(level="TRACE")
    {"outcome" => "success"}
    [standalone@localhost:9999 /]
    

手順11.15 ターゲットの設定

  • 次の構文で write-attribute オペレーションを使用します。HANDLER はコンソールログハンドラーの名前に置き換えます。TARGET は、システムエラーストリームの場合には System.err に、標準出力ストリームの場合には System.out に置き換えてください。
     /subsystem=logging/console-handler=HANDLER:write-attribute(name="target", value="TARGET") 

    例11.15

    [standalone@localhost:9999 /] /subsystem=logging/console-handler=ERRORCONSOLE:write-attribute(name="target", value="System.err")
    {"outcome" => "success"}
    [standalone@localhost:9999 /]
    

手順11.16 エンコーディングの設定

  • 次の構文で write-attribute オペレーションを使用します。HANDLER はコンソールログハンドラーの名前に置き換えます。ENCODING は必要な文字エンコーディングシステムの名前に置き換えます。
     /subsystem=logging/console-handler=HANDLER:write-attribute(name="encoding", value="ENCODING") 

    例11.16

    [standalone@localhost:9999 /] /subsystem=logging/console-handler=ERRORCONSOLE:write-attribute(name="encoding", value="utf-8")     
    {"outcome" => "success"}
    [standalone@localhost:9999 /]
    

手順11.17 フォーマッターの設定

  • 次の構文で write-attribute オペレーションを使用します。HANDLER はコンソールログハンドラーの名前に置き換えます。FORMAT は必要なフォーマッターの文字列に置き換えます。
     /subsystem=logging/console-handler=HANDLER:write-attribute(name="formatter", value="FORMAT") 

    例11.17

    [standalone@l/subsystem=logging/console-handler=ERRORCONSOLE:write-attribute(name="formatter", value="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"))
    {"outcome" => "success"}
    [standalone@localhost:9999 /]
    

手順11.18 自動フラッシュの設定

  • 次の構文で write-attribute オペレーションを使用します。HANDLER はコンソールログハンドラーの名前に置き換えます。このハンドラーが出力を直ちに書き込むようにするには、BOOLEANtrue に置き換えます。
     /subsystem=logging/console-handler=HANDLER:write-attribute(name="autoflush", value="BOOLEAN") 

    例11.18

    [standalone@localhost:9999 /] /subsystem=logging/console-handler=ERRORCONSOLE:write-attribute(name="autoflush", value="true")                                  
    {"outcome" => "success"}
    [standalone@localhost:9999 /]
    

手順11.19 コンソールログハンドラーの削除

  • 次の構文で remove オペレーションを使用します。HANDLER は削除するコンソールログハンドラーの名前に置き換えます。
     /subsystem=logging/console-handler=HANDLER:remove 

    例11.19

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