14.3.4. CLI でのファイルログハンドラーの設定
- 新しいファイルログハンドラーの追加
- ファイルログハンドラーの設定表示
- ハンドラーのログレベルの設定
- ハンドラーの追加動作の設定
- ハンドラーによる自動フラッシュ使用の有無を設定
- ハンドラーの出力に使用されるエンコーディングの設定
- ログハンドラーが書き込むファイルの指定
- ハンドラーの出力に使用されるフォーマッターの設定
- ファイルログハンドラーの削除
重要
/subsystem=logging/ ではなく /subsystem=logging/logging-profile=NAME/ になります。
- ファイルログハンドラーの追加
- 次の構文で
add操作を使用します。PATH をログが書き込まれるファイルのファイル名に置き換えます。DIR をファイルを格納するディレクトリーの名前に置き換えます。DIR の値はパス変数に指定できます。/subsystem=logging/file-handler=HANDLER:add(file={"path"=>"PATH", "relative-to"=>"DIR"})例14.20 ファイルログハンドラーの追加
[standalone@localhost:9999 /] /subsystem=logging/file-handler=accounts_log:add(file={"path"=>"accounts.log", "relative-to"=>"jboss.server.log.dir"}) {"outcome" => "success"} [standalone@localhost:9999 /] - ファイルログハンドラー設定の表示
- 次の構文で
read-resource操作を使用します。HANDLER はファイルログハンドラーの名前に置き換えます。/subsystem=logging/file-handler=HANDLER:read-resource
例14.21 read-resource 操作の使用
[standalone@localhost:9999 /] /subsystem=logging/file-handler=accounts_log:read-resource { "outcome" => "success", "result" => { "append" => true, "autoflush" => true, "encoding" => undefined, "file" => { "path" => "accounts.log", "relative-to" => "jboss.server.log.dir" }, "filter" => undefined, "formatter" => "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n", "level" => undefined } } - ログレベルの設定
- 次の構文で
write-attribute操作を使用します。HANDLER はファイルログハンドラーの名前に置き換えます。LOG_LEVEL_VALUE は設定するログレベルに置き換えます。/subsystem=logging/file-handler=HANDLER:write-attribute(name="level", value="LOG_LEVEL_VALUE")
例14.22 ログレベルの変更
/subsystem=logging/file-handler=accounts_log:write-attribute(name="level", value="DEBUG") {"outcome" => "success"} [standalone@localhost:9999 /] - 追加動作の設定
- 次の構文で
write-attribute操作を使用します。HANDLER はファイルログハンドラーの名前に置き換えます。アプリケーションサーバーが起動されるたびに新しいログファイルを作成する必要がある場合は、BOOLEAN を false に置き換えます。アプリケーションサーバーが同じファイルを使用し続ける必要がある場合は、BOOLEAN をtrueに置き換えます。/subsystem=logging/file-handler=HANDLER:write-attribute(name="append", value="BOOLEAN")
例14.23 追加プロパティーの変更
[standalone@localhost:9999 /] /subsystem=logging/file-handler=accounts_log:write-attribute(name="append", value="true") { "outcome" => "success", "response-headers" => { "operation-requires-reload" => true, "process-state" => "reload-required" } } [standalone@localhost:9999 /]この変更を反映するには、JBoss EAP 6 を再起動する必要があります。 - 自動フラッシュの設定
- 次の構文で
write-attribute操作を使用します。HANDLER はファイルログハンドラーの名前に置き換えます。このハンドラーが出力を直ちに書き込むようにするには、BOOLEAN をtrueに置き換えます。/subsystem=logging/file-handler=HANDLER:write-attribute(name="autoflush", value="BOOLEAN")
例14.24 自動フラッシュプロパティーの変更
[standalone@localhost:9999 /] /subsystem=logging/file-handler=accounts_log:write-attribute(name="autoflush", value="false") { "outcome" => "success", "response-headers" => {"process-state" => "reload-required"} } [standalone@localhost:9999 /]この変更を反映するには、JBoss EAP 6 を再起動する必要があります。 - エンコーディングの設定
- 次の構文で
write-attribute操作を使用します。HANDLER はファイルログハンドラーの名前に置き換えます。ENCODING は必要な文字エンコーディングシステムの名前に置き換えます。/subsystem=logging/file-handler=HANDLER:write-attribute(name="encoding", value="ENCODING")
例14.25 エンコーディングの設定
[standalone@localhost:9999 /] /subsystem=logging/file-handler=accounts_log:write-attribute(name="encoding", value="utf-8") {"outcome" => "success"} - ログハンドラーが書き込むファイルの変更
- 次の構文で
write-attribute操作を使用します。PATH をログが書き込まれるファイルのファイル名に置き換えます。DIR をファイルを格納するディレクトリーの名前に置き換えます。DIR の値はパス変数を指定できます。/subsystem=logging/file-handler=HANDLER:write-attribute(name="file", value={"path"=>"PATH", "relative-to"=>"DIR"})例14.26 ログハンドラーが書き込むファイルの変更
[standalone@localhost:9999 /] /subsystem=logging/file-handler=accounts_log:write-attribute(name="file", value={"path"=>"accounts-debug.log", "relative-to"=>"jboss.server.log.dir"}) {"outcome" => "success"} [standalone@localhost:9999 /] - フォーマッターの設定
- 次の構文で
write-attribute操作を使用します。HANDLER はファイルログハンドラーの名前に置き換えます。FORMAT は必要なフォーマッターの文字列に置き換えます。/subsystem=logging/file-handler=HANDLER:write-attribute(name="formatter", value="FORMAT")
例14.27 フォーマッターの設定
[standalone@localhost:9999 /] /subsystem=logging/file-handler=accounts-log:write-attribute(name="formatter", value="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n") {"outcome" => "success"} [standalone@localhost:9999 /] - ファイルログハンドラーの削除
- 次の構文で
remove操作を使用します。HANDLER は削除するファイルログハンドラーの名前に置き換えます。/subsystem=logging/file-handler=HANDLER:remove
例14.28 ファイルログハンドラーの削除
[standalone@localhost:9999 /] /subsystem=logging/file-handler=accounts_log:remove {"outcome" => "success"} [standalone@localhost:9999 /]ログハンドラーは、ログカテゴリーまたは非同期ログハンドラーによって参照されていない場合にのみ削除できます。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.