Change logging levels using CLI commands in JBoss EAP 6 or 7
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6
- 7
- JBoss EAP Command Line Interface (CLI)
- Red Hat Single Sign-On (RH-SSO) 7.x
- Logging
Issue
- Change the logging levels using the CLI.
- I need to enable logging on a specific package.
- The Logging subsystem and logging.properties are set to INFO as a minimum, yet I see TRACE, DEBUG, FINE, FINER on module package names
- How I can start in debug mode?
- How can we change logging without a restart?
- In JBoss EAP 4,
jboss-services.xmlcould be used to log when configuration changes take effect. Is there something similar newer versions?
Resolution
Connect to CLI terminal using either $EAP_HOME/bin/jboss-cli.sh or %EAP_HOME%\bin\jboss-cli.bat script and run following command:
-
To change logging level for all modules use the following CLI command, replacing NEW_LOGGING_LEVEL with the desired logging level:
/subsystem=logging/root-logger=ROOT:write-attribute(name=level,value=NEW_LOGGING_LEVEL) -
To create logging for a specific package run the following command:
/subsystem=logging/logger=package.name:add(category=package.name,level=INFO,use-parent-handlers=true)
The above command adds a logging entry for the specified package at the "INFO" level. Also can specify other options like TRACE or FINE. The package name can be something like org.jboss.security or org.picketlink for example.
-
To change the logging level of the existing package, use the following command, replacing NEW_LOGGING_LEVEL with the desired logging level. Note that logging level changes done like this via CLI are applied without a restart.
/subsystem=logging/logger=package.name:change-log-level(level=NEW_LOGGING_LEVEL)
NOTE: All JBoss- CLI commands above are specific for the Standalone mode, in case of running in Domain mode, make sure to prefix the command using /profile=Profile_Name/, where Profile_Name is the profile being used. For example:
/profile=Profile_Name/subsystem=logging/root-logger=ROOT:write-attribute(name=level,value=NEW_LOGGING_LEVEL)
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.