This tutorial will teach you how to change the default log level in WildFly using the management instruments available
There are two simple ways to change log level in WildFly. You can either:
- Change the ROOT logger setting
- Change the single Logger verbosity
Let’s see the pros and cons of each approach.
Change the Root Logger settings
This is a brute-force option which will change the log level of all loggers available in the WildFly application server. All classes that don’t have a configured logger, will inherit from the ROOT logger.
To do that, run the following command from the CLI:
As a result, your XML configuration will change accordingly:
<root-logger> <level name="DEBUG"/> <handlers> <handler name="CONSOLE"/> <handler name="FILE"/> </handlers> </root-logger>
You can then restore it as follows:
We don’t recommend using this approach though as it will generate a large amount of logs. Unless you don’t have a clue about the package you want to debug, it is advisable to change the specific logger verbosity.
Change the Single Logger Verbosity
This is the recommended approach. Pick up a namespace (f.e. “com.acme”) and change the level to DEBUG (or one of the available log levels). Also
Finally, it is worth mentioning that also Log Handlers have a Log Verbosity Level. You can set it as follows:
Note: in case the single Logger level is set to a different value than the Handler’s level, the Logger level will prevail, as it’s more specific attribute.
Changing the Logger Verbosity on OpenShift
if your application server is running on OpenShift, you can either provide a custom standalone-openshift.xml file or set the logger using the rsh shell command.
For example, to add a Logger for the com.acme package:
oc exec <POD_NAME> -- /opt/eap/bin/jboss-cli.sh -c --command="/subsystem=logging/logger=com.acme:add(level=DEBUG)"
You can then remove it when it’s not needed any more:
oc exec <POD_NAME> -- /opt/eap/bin/jboss-cli.sh -c --command="/subsystem=logging/logger=com.acme:remove()"