WildFly Logging Subsystem CLI Configuration: Difference between revisions
(8 intermediate revisions by the same user not shown) | |||
Line 12: | Line 12: | ||
A complex example: | A complex example: | ||
{{External|https://github.com/NovaOrdis/playground/blob/master/jboss/cli/bash-script-examples/update-logging-subsystem-handler.sh}} | |||
=Change | =Change a Logger Log Level= | ||
= | <pre> | ||
/subsystem=logging/logger=com.arjuna:write-attribute(name="level",value="TRACE") | |||
</pre> | |||
Adjust for the logger name. | |||
No reboot is required. | |||
=Changing a Handler Log Level= | |||
<pre> | |||
/subsystem=logging/size-rotating-file-handler=FILE:write-attribute(name="level",value="TRACE") | |||
</pre> | |||
Adjust for the handler name. | |||
No reboot is required. | |||
=Changing Root Logger Log Level= | |||
<pre> | |||
/subsystem=logging/root-logger=ROOT:write-attribute(name="level",value="TRACE") | |||
</pre> | |||
No reboot is required. | |||
=Example of Multiple Changes that Enable Tracing on a Specific Layer= | |||
This is used to troubleshoot HornetQ. Save the following content into a text file <tt>enable-hornetq-tracing.cli</tt>: | |||
<pre> | |||
batch | |||
/subsystem=logging/logger=com.arjuna:write-attribute(name="level",value="TRACE") | |||
/subsystem=logging/logger=org.hornetq:write-attribute(name="level",value="TRACE") | |||
/subsystem=logging/root-logger=ROOT:write-attribute(name="level",value="TRACE") | |||
/subsystem=logging/size-rotating-file-handler=FILE:write-attribute(name="level",value="TRACE") | |||
run-batch | |||
</pre> | |||
The content of the file can be run with: | |||
<pre> | |||
jboss-cli.sh -c --file=enable-hornetq-tracing.cli | |||
</pre> | |||
The reverse is: | |||
<pre> | |||
batch | |||
/subsystem=logging/logger=com.arjuna:write-attribute(name="level",value="INFO") | |||
/subsystem=logging/logger=org.hornetq:write-attribute(name="level",value="INFO") | |||
/subsystem=logging/root-logger=ROOT:write-attribute(name="level",value="INFO") | |||
/subsystem=logging/size-rotating-file-handler=FILE:write-attribute(name="level",value="INFO") | |||
run-batch | |||
</pre> | |||
=Adding a Periodic Rotating File Log Handler= | =Adding a Periodic Rotating File Log Handler= |
Latest revision as of 20:06, 9 June 2017
External
- Logging Configuration in the CLI https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html/Administration_and_Configuration_Guide/sect-Logging_Configuration_in_the_CLI.html
Internal
Example
A complex example:
Change a Logger Log Level
/subsystem=logging/logger=com.arjuna:write-attribute(name="level",value="TRACE")
Adjust for the logger name.
No reboot is required.
Changing a Handler Log Level
/subsystem=logging/size-rotating-file-handler=FILE:write-attribute(name="level",value="TRACE")
Adjust for the handler name.
No reboot is required.
Changing Root Logger Log Level
/subsystem=logging/root-logger=ROOT:write-attribute(name="level",value="TRACE")
No reboot is required.
Example of Multiple Changes that Enable Tracing on a Specific Layer
This is used to troubleshoot HornetQ. Save the following content into a text file enable-hornetq-tracing.cli:
batch /subsystem=logging/logger=com.arjuna:write-attribute(name="level",value="TRACE") /subsystem=logging/logger=org.hornetq:write-attribute(name="level",value="TRACE") /subsystem=logging/root-logger=ROOT:write-attribute(name="level",value="TRACE") /subsystem=logging/size-rotating-file-handler=FILE:write-attribute(name="level",value="TRACE") run-batch
The content of the file can be run with:
jboss-cli.sh -c --file=enable-hornetq-tracing.cli
The reverse is:
batch /subsystem=logging/logger=com.arjuna:write-attribute(name="level",value="INFO") /subsystem=logging/logger=org.hornetq:write-attribute(name="level",value="INFO") /subsystem=logging/root-logger=ROOT:write-attribute(name="level",value="INFO") /subsystem=logging/size-rotating-file-handler=FILE:write-attribute(name="level",value="INFO") run-batch
Adding a Periodic Rotating File Log Handler
No restart is required.
batch /subsystem=logging/periodic-rotating-file-handler=TEST:add(file={"path"=>"test.log", "relative-to"=>"jboss.server.log.dir"}, suffix=".yyyy-MM-dd", append="true") /subsystem=logging/periodic-rotating-file-handler=TEST:write-attribute(name="formatter", value="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n") /subsystem=logging/periodic-rotating-file-handler=TEST:write-attribute(name="autoflush", value="true") run-batch
System properties can be specified without "${}"
The "formatter" attribute specified above expands as:
<periodic-rotating-file-handler ...> ... <formatter> <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/> </formatter> ... </periodic-rotating-file-handler>
The result of the above set of CLI operations is:
<server ...> ... <profile> <subsystem xmlns="urn:jboss:domain:logging:1.5"> ... <periodic-rotating-file-handler name="TEST" autoflush="true"> <formatter> <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/> </formatter> <file relative-to="jboss.server.log.dir" path="test.log"/> <suffix value=".yyyy-MM-dd"/> <append value="true"/> </periodic-rotating-file-handler> ... </subsystem> ... </profile> ... </server>
For general considerations on adding arbitrary management nodes and attributes see:
Removing a Log Handler
No restart is required.
/subsystem=logging/file-handler=TEST:remove
However, a log handler can only be removed if it is not being referenced by a log category or an async log handler, otherwise an error message similar to the following is shown:
{ "outcome" => "failed", "failure-description" => "JBAS011558: Handler TEST is attached to the following loggers and cannot be removed; [org.infinispan, org.infinispan.server.endpoint, org.jboss.as.clustering.infinispan]", "rolled-back" => true }
For general considerations on removing an arbitrary management model node:
Configuring a Category to Use a Specific Handler
The logging category has a specialized "add-handler" operation, that can be used as shown below. No restart is required. The handler must exist when they're added to the category. For an example of how to add a handler see "Adding a Periodic Rotating File Log Handler" section.
/subsystem=logging/logger=com.example:add-handler(name="TEST-HANDLER")
Removing a Handler from a Category
The logging category has a specialized "remove-handler" operation, that can be used as shown below. No restart is required.
/subsystem=logging/logger=com.example:remove-handler(name="TEST-HANDLER")