11.3.2. Configure a Log Category in the CLI
Log categories can be added, removed and edited in the CLI.
The main tasks you will perform to configure a log category are:
- Display the configuration of a log category.
- Add a new log category.
- Set the log level.
- Add log handlers to a log category.
- Remove log handlers from a log category.
- Remove a log category.
- Display a log category configuration
- Use the
read-resource
operation with the following syntax. Replace CATEGORY with the name of the category./subsystem=logging/logger=CATEGORY:read-resource
Example 11.5. Log Category read-resource operation
[standalone@localhost:9999 /] /subsystem=logging/logger=org.apache.tomcat.util.modeler:read-resource { "outcome" => "success", "result" => { "filter" => undefined, "handlers" => undefined, "level" => "WARN", "use-parent-handlers" => true } } [standalone@localhost:9999 /]
- Add a log category
- Use the
add
operation with the following syntax. Replace CATEGORY with the category to be added./subsystem=logging/logger=CATEGORY:add
Example 11.6. Adding a new log category
[standalone@localhost:9999 /] /subsystem=logging/logger=com.company.accounts.rec:add {"outcome" => "success"} [standalone@localhost:9999 /]
- Set the log level
- Use the
write-attribute
operation with the following syntax. Replace CATEGORY with the name of the log category and LEVEL with the log level that is to be set./subsystem=logging/logger=CATEGORY:write-attribute(name="level", value="LEVEL")
Example 11.7. Setting a log level
[standalone@localhost:9999 /] /subsystem=logging/logger=com.company.accounts.rec:write-attribute(name="level", value="DEBUG") {"outcome" => "success"} [standalone@localhost:9999 /]
- Set the log category to use the log handlers of the root logger.
- Use the
write-attribute
operation with the following syntax. Replace CATEGORY with the name of the log category. Replace BOOLEAN with true for this log category to use the handlers of the root logger. Replace it with false if it is to use only its own assigned handlers./subsystem=logging/logger=CATEGORY:write-attribute(name="use-parent-handlers", value="BOOLEAN")
Example 11.8. Setting use-parent-handlers
[standalone@localhost:9999 /] /subsystem=logging/logger=com.company.accounts.rec:write-attribute(name="use-parent-handlers", value="true") {"outcome" => "success"} [standalone@localhost:9999 /]
- Add a log handlers to a log category
- Use the
assign-handler
operation with the following syntax. Replace CATEGORY with the name of the category and HANDLER with the name of the handler to be added./subsystem=logging/logger=CATEGORY:assign-handler(name="HANDLER")
The log handler must already have been created before it can be added to the root logger.Example 11.9. Adding a log handler
[standalone@localhost:9999 /] /subsystem=logging/logger=com.company.accounts.rec:assign-handler(name="AccountsNFSAsync") {"outcome" => "success"} [standalone@localhost:9999 /]
- Remove a log handler from a log category
- Use the
unassign-handler
operation with the following syntax. Replace CATEGORY with the name of the category and HANDLER with the name of the log handler to be removed./subsystem=logging/logger=CATEGORY:unassign-handler(name="HANDLER")
Example 11.10. Removing a log handler
[standalone@localhost:9999 /] /subsystem=logging/root-logger=ROOT:root-logger-unassign-handler(name="AccountsNFSAsync") {"outcome" => "success"} [standalone@localhost:9999 /]
- Remove a category
- Use the
remove
operation with the following syntax. Replace CATEGORY with the name of the category to be removed./subsystem=logging/logger=CATEGORY:remove
Example 11.11. Removing a log category
[standalone@localhost:9999 /] /subsystem=logging/logger=com.company.accounts.rec:remove {"outcome" => "success"} [standalone@localhost:9999 /]