Change logging levels using CLI commands in JBoss EAP
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6.x
- 7.x
- 8.x
- JBoss EAP Command Line Interface (CLI)
- Red Hat Single Sign-On (RH-SSO) 7.x
- Logging
Issue
- Change the logging levels using the CLI.
- Enable logging on a specific package.
- The logging subsystem and
logging.propertiesare set to INFO as a minimum, yet TRACE, DEBUG, FINE, and FINER messages appear for module package names. - How to start the server in debug mode?
- How to change logging levels without a restart?
- In JBoss EAP 4,
jboss-services.xmlcould be used to log when configuration changes take effect. Is there something similar in newer versions?
Resolution
Connect to the management CLI using either $EAP_HOME/bin/jboss-cli.sh -c or %EAP_HOME%\bin\jboss-cli.bat -c and run the appropriate command below. Logging level changes made through the CLI take effect immediately, without a server restart.
-
To change the logging level for all categories, modify the root logger, replacing
NEW_LOGGING_LEVELwith the desired level:/subsystem=logging/root-logger=ROOT:write-attribute(name=level,value=NEW_LOGGING_LEVEL) -
To enable logging for a specific package that does not yet have a logger defined:
/subsystem=logging/logger=package.name:add(category=package.name,level=INFO,use-parent-handlers=true)The command adds a logger for the specified package at the
INFOlevel. Other levels such asDEBUGorTRACEcan be specified, andjava.util.logginglevel names such asFINE,FINER, andFINESTare also accepted. The package name can be, for example,org.jboss.securityorio.undertow. -
To change the logging level of an existing logger:
/subsystem=logging/logger=package.name:write-attribute(name=level,value=NEW_LOGGING_LEVEL)Note: The
change-log-leveloperation performs the same change but is deprecated (deprecated since logging subsystem model 1.2.0; JBoss EAP 8 returns warningWFLYCTL0449when it is invoked). Usewrite-attributeinstead.
Note: The commands above apply to standalone mode. In domain mode, prefix each command with /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.