14.3. Logging Configuration in the CLI

Prerequisite

The Management CLI must be running and connected to the relevant JBoss EAP instance. For further information see Section 3.5.2, “Launch the Management CLI”

14.3.1. Configure the Root Logger with the CLI

The root logger configuration can be viewed and edited using the Management CLI.
The main tasks you will perform to configure the root logger are:
  • Add log handlers to the root logger.
  • Display the root logger configuration.
  • Change the log level.
  • Remove log handlers from the root logger.

Important

When configuring a root logger in a logging profile for a standalone system, the root of the configuration path is /subsystem=logging/logging-profile=NAME/ instead of /subsystem=logging/.
For a managed domain, you must specify which profile to use. You must add the profile name to the beginning of the configuration path for a managed domain, replacing /subsystem=logging/ with /profile=NAME/subsystem=logging/.
Add a Log Handler to the Root Logger
Use the add-handler operation with the following syntax where HANDLER is the name of the log handler to be added.
/subsystem=logging/root-logger=ROOT:add-handler(name="HANDLER")
The log handler must already have been created before it can be added to the root logger.

Example 14.1. Root Logger add-handler operation

[standalone@localhost:9999 /] /subsystem=logging/root-logger=ROOT:add-handler(name="FILE")
{"outcome" => "success"}
Display the Contents of the Root Logger Configuration
Use the read-resource operation with the following syntax.
/subsystem=logging/root-logger=ROOT:read-resource

Example 14.2. Root Logger read-resource operation

[standalone@localhost:9999 /] /subsystem=logging/root-logger=ROOT:read-resource                                  
{
   "outcome" => "success",
   "result" => {
        "filter" => undefined,
        "filter-spec" => undefined,
        "handlers" => [
            "CONSOLE",
            "FILE"
      ],
      "level" => "INFO"
   }
}
Set the Log Level of the Root Logger
Use the write-attribute operation with the following syntax where LEVEL is one of the supported log levels.
/subsystem=logging/root-logger=ROOT:write-attribute(name="level", value="LEVEL")

Example 14.3. Root Logger write-attribute operation to set the log level

[standalone@localhost:9999 /] /subsystem=logging/root-logger=ROOT:write-attribute(name="level", value="DEBUG")
{"outcome" => "success"}
Remove a Log Handler from the Root Logger
Use the remove-handler with the following syntax, where HANDLER is the name of the log handler to be removed.
/subsystem=logging/root-logger=ROOT:remove-handler(name="HANDLER")

Example 14.4. Remove a Log Handler

[standalone@localhost:9999 /] /subsystem=logging/root-logger=ROOT:remove-handler(name="FILE")
{"outcome" => "success"}